I want to replace below class with active
class in menu:
.current-menu-item
and
.current_page_item
I am already using a menu callback which add a class dropdown
in child menu:
class foundation_navigation extends Walker_Nav_Menu {
function start_lvl(&$output, $depth) {
$indent = str_repeat("t", $depth);
$output .= "n$indent<a href="#" class="dropdown-toggle"><span> </span></a><ul class="dropdown">n";
}
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
$id_field = $this->db_fields['id'];
if ( !empty( $children_elements[ $element->$id_field ] ) ) {
$element->classes[] = 'has-dropdown';
}
Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
}
Add this line at top of your display element function:
Add this line at bottom of your display element function:
Add this function somewhere in your themes
functions.php
:Search for current_page_item. I found it four times total in post-template.php and nav-menu-template.php. Then replace it with active.