好吧,根据你的代码,我觉得你在处理一个儿童主题,或者你自己的主题这个答案是基于这个假设。
首先,您需要注册(新)菜单。
// -- This will go in functions.php
add_action( \'init\', \'register_my_menus\' );
function register_my_menus() {
register_nav_menus(
array(
\'menu-1\' => __( \'Menu 1\' ),
\'menu-2\' => __( \'Menu 2\' ),
\'menu-3\' => __( \'Menu 3\' )
)
);
}
然后需要在中为菜单指定位置
wp-admin > appearance > menus
然后,您可以定制步行器
// functions.php
class your_new_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl(&$output, $depth = 0, $args = Array()) {
$output .= \'<ul class="sub-menu">\';
}
function end_lvl(&$output, $depth = 0, $args = Array()) {
$output .= \'</ul>\';
}
}
然后,当你准备好调用新菜单时,让我们输入
header.php
<!-- header.php -- assuming php is closed at this point -->
<div class="navbar-header">
<?php wp_nav_menu(array(
\'theme_location\' => \'menu-1\',
// \'items_wrap\' => \'nav-wrap\', un comment if you want
\'container_class\' => \'class1 class2\',
\'walker\' => new your_new_Walker_Nav_Menu
));
?>
</div>