I am creating custom Wordpress theme using a starter theme _Underscores. I am also using Bootstrap as a front-end framework.
I would like to modify wp_nav_menu so th
To also highlight the menu item when one of the child pages is active, also check for the other class (current-page-ancestor) like below:
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class ($classes, $item) {
if (in_array('current-page-ancestor', $classes) || in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}