I'm using the Wordpress Bootstrap theme as my base theme.
It uses the following code to add the class "active" to any links in the header if the user is currently on that page:
add_filter('nav_menu_css_class', 'add_active_class', 10, 2 );
function add_active_class($classes, $item) {
if($item->menu_item_parent == 0 && in_array('current-menu-item', $classes)) {
$classes[] = "active";
}
return $classes;
}
However, I have multiple pages that I want to display as "active" when the user is not actually on that specific page. For example, users may sometimes be on "tutorials-by-topic" (Tutorials by Topic) but I want the link titled "Tutorials" to be displayed as the active link. I have four pages I want to do this way. I have tried different conditionals, etc. in the add_active_class function but I've had no luck. Any guidance? Thanks!