I created some custom post types and custom taxonomies, if I'm on an archive page of the custom taxonomy, the Blog menu item is highlighted due to the current_page_parent
class.
Well this is obviously false and I want to remove the class, but I also want to add it to another menu item.
How can I add and remove the current_page_parent
class dynamically for all my custom taxonomies?
I'm currently removing the class with
function wpdev_nav_classes( $classes ) {
if( is_archive() ){
$classes = array_diff( $classes, array( 'current_page_parent' ) );
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'wpdev_nav_classes', 10, 2 );
but I have no clue on how to add it to an other menu item, let's call the item Example.
nav_menu_css_class
filter is the menu item, you can check the title, ID, etc.. – Milo Aug 22 '16 at 15:24