I created a "category" menu in Appeareances > menu, which appears in my top menu. Then when I am on this page and this menu is active (class : current-menu-item), my "blog" menu, which is the posts page, is also active with the class current-menu-item.
I'd like to have only my category menu active when I am on this page. Any idea what to tune in the functions.php ?
I am using my own child theme of BeTheme.
Thanks
I created a "category" menu in Appeareances > menu, which appears in my top menu. Then when I am on this page and this menu is active (class : current-menu-item), my "blog" menu, which is the posts page, is also active with the class current-menu-item.
I'd like to have only my category menu active when I am on this page. Any idea what to tune in the functions.php ?
I am using my own child theme of BeTheme.
Thanks
Add this to your child theme’s functions.php:
add_filter('nav_menu_css_class', 'fix_category_menu_active_class', 10, 2); function fix_category_menu_active_class($classes, $item) { // If we're on a category archive if (is_category()) { // Get the ID of the blog page (posts page) $blog_page_id = get_option('page_for_posts'); // If this menu item is the blog page if ($item->object_id == $blog_page_id) { // Remove the active classes $classes = array_diff($classes, array( 'current-menu-item', 'current_page_item', 'current_page_parent', 'current-menu-ancestor' )); } } return $classes; }