Some of my previous projects involved re-developing HTML-built websites in to bespoke WordPress themes, majority of these sites being built using Bootstrap.
When it came to creating the menu, I found it easier to just add the ‘active’ class to the ‘current menu item’ rather than amending the Bootstrap CSS to apply active styles to .current-menu-item rather than .active.
add_filter('nav_menu_css_class' , 'active_nav_class' , 10 , 2);
function active_nav_class($classes, $item){
if( in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
Whether you have a question, want to learn more about our services, or simply wish to connect, don’t hesitate to get in touch. We’re here to help!
Send an email"*" indicates required fields