您需要针对适当的theme_location
.
假设您已使用定义了多个导航菜单位置register_nav_menus()
在函数中。php:
<?php
register_nav_menus( array(
\'primary-menu\' => \'Primary Menu\',
\'secondary-menu\' => \'Secondary Menu\'
) );
?>
然后你打电话
wp_nav_menu()
使用适当的
theme_location
如上所述,以及任何其他相关参数,例如:
<?php
wp_nav_menu( array(
\'theme_location\' => \'primary-menu\',
\'menu_class\' => \'topnav\'
) );
wp_nav_menu( array(
\'theme_location\' => \'secondary-menu\',
\'menu_class\' => \'subnav\'
) );
?>
另外,请注意您的一些论点,例如
menu_order
, 不是的有效参数
wp_nav_menu()
.
Here are the defaults:
<?php $defaults = array(
\'theme_location\' => ,
\'menu\' => ,
\'container\' => \'div\',
\'container_class\' => \'menu-{menu slug}-container\',
\'container_id\' => ,
\'menu_class\' => \'menu\',
\'menu_id\' => ,
\'echo\' => true,
\'fallback_cb\' => \'wp_page_menu\',
\'before\' => ,
\'after\' => ,
\'link_before\' => ,
\'link_after\' => ,
\'items_wrap\' => \'<ul id=\\"%1$s\\" class=\\"%2$s\\">%3$s</ul>\',
\'depth\' => 0,
\'walker\' => );
?>