Add a custom class to active menu item.
<?php
/**
* Add a custom class to active menu item.
*/
add_filter('nav_menu_css_class', function($classes) {
if (in_array('current-menu-item', $classes) || in_array('current-menu-parent', $classes) || in_array('current-menu-ancestor', $classes)) {
$classes[] = 'active';
}
return $classes;
});
?>
functions.php