我注册了两个菜单top menu和main menu。
我在管理面板上创建了两个菜单,并为每个菜单分配了一个菜单(不同的项目)
但当我查看前端时,我看到这两个菜单具有相同的项目,主菜单的id为“menu-top-menu-1”
以下是我所拥有的:
功能。php
function register_my_menus() {
register_nav_menus (array(
\'main-menu\' => \'Main Menu\',
\'top-menu\' => \'Top Menu\',
));
}
add_action( \'init\', \'register_my_menus\' );
标题。php
顶部菜单:
<div class=" top-menu-container">
<?php wp_nav_menu(array(
\'container\' => \'nav\',
\'container_class\' => \'container\',
\'item_location\' => \'top-menu\',
\'menu_class\' => \'nav top-menu pull-right\',
));
?>
</div>
主菜单:
<div class="container">
<div class="logo col-xs-12 col-sm-12 col-md-3 col-lg-4">
<a href="<?php echo home_url(); ?>"><img class="block-center " src="<?php print IMAGES; ?>/logo.png" alt="<?php bloginfo(\'name\'); ?> | <?php bloginfo(\'description\'); ?>"/></a>
</div>
<nav class="navbar navbar-default col-xs-12 col-sm-12 col-md-9 col-lg-8" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-menu-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse nav-wrap" id="main-menu-toggle">
<?php wp_nav_menu(array(
\'item_location\' => \'main-menu\',
\'container_class\' => \'collapse navbar-collapse nav-wrap\',
\'container_id\' => \'main-menu-toggle\',
\'menu_class\' => \'nav navbar-nav main-menu\',
));
?>
</div>
</nav>
</div>
这是顶部菜单和主菜单的渲染输出
<nav class="container">
<ul id="menu-top-menu" class="nav top-menu pull-right">
<li id="menu-item-4" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-4"><a href="#">CanHerp</a></li>
<li id="menu-item-5" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-5"><a href="#">Rescues</a></li>
<li id="menu-item-6" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6"><a href="#">Breeders</a></li>
<li id="menu-item-7" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-7"><a href="#">Forums</a></li>
</ul>
</nav>
<div class="collapse navbar-collapse nav-wrap" id="main-menu-toggle">
<div id="main-menu-toggle" class="collapse navbar-collapse nav-wrap">
<ul id="menu-top-menu-1" class="nav navbar-nav main-menu">
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-4"><a href="#">CanHerp</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-5"><a href="#">Rescues</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6"><a href="#">Breeders</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-7"><a href="#">Forums</a></li>
</ul>
</div>
</div>
我还想知道这是否是处理引导响应菜单(主菜单)的最佳方法。