qlstudio

4 Trees - Custom Post Type / Child Theme / functions.php

Nov 17th, 2012
43
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * init functions
  3.  */
  4. add_action( 'init','ftc_init', 0 );
  5. function ftc_init() {
  6.    
  7.     // build custom post type ##
  8.     ftc_cuztom();
  9.    
  10. }
  11.  
  12. /* cuztom CPT function */
  13. function ftc_cuztom() {
  14.    
  15.     $tree = new Cuztom_Post_Type( 'Tree', array(
  16.         'has_archive'           => false,
  17.         'menu_position'     => 5,
  18.         'supports'              => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'excerpt', 'comments' )
  19.     ));
  20.    
  21.     $taxonomy = register_cuztom_taxonomy( 'Tree Tag', 'tree', array(
  22.         'hierarchical'          => false,
  23.     ));
  24.    
  25.     $taxonomy = register_cuztom_taxonomy( 'Tree Category', 'tree' );
  26.    
  27.     $sidebar = register_cuztom_sidebar( array(
  28.         'name'                  => __( 'Tree Sidebar', 'ftchild' ),
  29.         'id'                    => 'sidebar-tree',
  30.         'description'           => __( 'Widgets shown in the Tree sidebar area.', 'ftchild' ),
  31.         'before_title'          => '<h4>',
  32.         'after_title'           => '</h4>',
  33.         'before_widget'         => '<div class="sidepanel">',
  34.         'after_widget'          => '</div>',
  35.     ) );
  36.    
  37. }
  38.  
  39.  
  40. /*
  41.  * Fix CPT nav_menu highlight bug ##
  42.  * You need to edit menu-item-967 to match the ID of the page you add to contain your CPT ##
  43.  */
  44. add_filter('nav_menu_css_class', 'ftc_add_class_to_wp_nav_menu', 10, 2 );
  45. function ftc_add_class_to_wp_nav_menu( $classes, $item ) {
  46.      
  47.     switch (get_post_type()) {
  48.        
  49.         case 'tree': // we're viewing a custom post type, so remove the 'current_page_xxx and current-menu-item' from all menu items.
  50.            
  51.             $classes = array_filter( $classes, "ftf_remove_parent_classes" );
  52.  
  53.             // add the current page class to a specific menu item (replace ###).
  54.             if ( in_array('menu-item-967', $classes) ) {
  55.                $classes[] = 'current_page_parent';
  56.             }
  57.            
  58.         break;
  59.  
  60.     }
  61.     return $classes;
  62. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×