我使用" santone"主题哪里有2个自定义菜单。在功能代码中:
register_nav_menus( array(
'main_nav' => __( 'Main Navigation', 'metcreative' ),
'header_nav' => __( 'Header Navigation', 'metcreative' )
) );
}
在模板中:
$location_id = 'main_nav';
if (isset($menu_locations[ $location_id ])) {
foreach ($menus as $menu) {
if ($menu->term_id == $menu_locations[ $location_id ]) {
$menu_items = wp_get_nav_menu_items($menu);
foreach($menu_items as $menu_item){
if($menu_item->menu_item_parent == 0){
$parentMenus[$location_id][] = $menu_item;
}else{
$childMenus[$location_id][$menu_item->menu_item_parent][] = $menu_item;
}
}
break;
}
}
}
如何将css - 当前页面添加到此菜单,以突出显示当前页面? 提前谢谢
答案 0 :(得分:0)
您可以使用wordpress应用于菜单项。将应用于当前活动菜单的是“current-menu-item”
所以
.current-menu-item{
/* your css for hightlight */
}