Hi, I have set a custom blog posts page titled ‘news’ and want the ‘news’ navigation item to remain selected as current for all individual blog posts, category pages and tag pages.
I adapted the code from this topic and added it as an inside_navigation hook but it doesn’t appear to be working.
<?php
function be_menu_item_classes( $classes, $item, $args ) {
if( 'header' !== $args->theme_location )
return $classes;
if( ( is_singular( 'post' ) || is_category() || is_tag() ) && 'news' == $item->title )
$classes[] = 'current-menu-item';
return array_unique( $classes );
}
add_filter( 'nav_menu_css_class', 'be_menu_item_classes', 10, 3 );
?>
What am I doing wrong?
GP Premium 1.7.7