我使用“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 - 当前页面添加到此菜单,以突出显示当前页面? 提前致谢
最佳答案
您可以使用 wordpress 应用于菜单项的类。将应用于当前事件菜单的一个是 'current-menu-item'
所以
.current-menu-item{
/* your css for hightlight */
}
关于css - Wordpress 突出显示自定义菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23674182/