Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * init functions
- */
- add_action( 'init','ftc_init', 0 );
- function ftc_init() {
- // build custom post type ##
- ftc_cuztom();
- }
- /* cuztom CPT function */
- function ftc_cuztom() {
- $tree = new Cuztom_Post_Type( 'Tree', array(
- 'has_archive' => false,
- 'menu_position' => 5,
- 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'excerpt', 'comments' )
- ));
- $taxonomy = register_cuztom_taxonomy( 'Tree Tag', 'tree', array(
- 'hierarchical' => false,
- ));
- $taxonomy = register_cuztom_taxonomy( 'Tree Category', 'tree' );
- $sidebar = register_cuztom_sidebar( array(
- 'name' => __( 'Tree Sidebar', 'ftchild' ),
- 'id' => 'sidebar-tree',
- 'description' => __( 'Widgets shown in the Tree sidebar area.', 'ftchild' ),
- 'before_title' => '<h4>',
- 'after_title' => '</h4>',
- 'before_widget' => '<div class="sidepanel">',
- 'after_widget' => '</div>',
- ) );
- }
- /*
- * Fix CPT nav_menu highlight bug ##
- * You need to edit menu-item-967 to match the ID of the page you add to contain your CPT ##
- */
- add_filter('nav_menu_css_class', 'ftc_add_class_to_wp_nav_menu', 10, 2 );
- function ftc_add_class_to_wp_nav_menu( $classes, $item ) {
- switch (get_post_type()) {
- case 'tree': // we're viewing a custom post type, so remove the 'current_page_xxx and current-menu-item' from all menu items.
- $classes = array_filter( $classes, "ftf_remove_parent_classes" );
- // add the current page class to a specific menu item (replace ###).
- if ( in_array('menu-item-967', $classes) ) {
- $classes[] = 'current_page_parent';
- }
- break;
- }
- return $classes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement