I am creating a menu using this function:
function top_nav_menu( $theme_location ) {
if ( ($theme_location) && ($locations = get_nav_menu_locations()) && isset($locations[$theme_location]) ) {
$menu = get_term( $locations[$theme_location], 'nav_menu' );
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list = '<nav class="header__titlemenu__menu">' ."n";
$menu_list .= '<ul class="heading4">' ."n";
foreach( $menu_items as $key => $menu_item ) {
$menu_list .= '<li class="mr">' ."n";
$menu_list .= '<a href="' . $menu_item->url . '" class="list">' . strtoupper($menu_item->title) . '</a>' ."n";
$menu_list .= '</li>' ."n";
}
$menu_list .= '</ul>' ."n";
$menu_list .= '</nav>' ."n";
} else {
$menu_list = '<!-- no menu defined in location "'.$theme_location.'" -->';
}
echo $menu_list;
}
the problem is I want to highlight the current page I am on the menu but it seems not possible due when I apply a pseudoclass it applies to all the menu elements, maybe with a function or similar will be able to achieve that?