Custom post type – highlighting current menu item
-
I have created a custom post type called ‘teams’, this is working ok but when I click on teams on the menu the current menu item is not highlighting, I found this snippet to add to the funtions.php file which successfully removed the highlighting of the normal wordpress posts page which is the ‘training page’, im stumped with this one!, does anyone have any idea how to get this working?
Cheers!
add_editor_style( 'editor-style.css' ); function add_parent_url_menu_class( $classes = array(), $item = false ) { // Get current URL $current_url = current_url(); // Get homepage URL $homepage_url = trailingslashit( get_bloginfo( 'url' ) ); // Exclude 404 and homepage if( is_404() or $item->url == $homepage_url ) return $classes; if ( get_post_type() == "team" ) { unset($classes[array_search('current_page_parent',$classes)]); if ( isset($item->url) ) if ( strstr( $current_url, $item->url) ) $classes[] = 'current-menu-item'; } return $classes; }
[please mark any posted code – https://codex.www.ads-software.com/Forum_Welcome#Posting_Code ]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Custom post type – highlighting current menu item’ is closed to new replies.