Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I registered two menus top-menu and main-menu.

I created two menu on the admin panel and assigned one to each (different items)

But when I view the front end, I see that the two menus have the same items, and the main menu has an id "menu-top-menu-1"

Here is what I have:

functions.php

function register_my_menus() {
    register_nav_menus (array(
        'main-menu' => 'Main Menu',
        'top-menu' => 'Top Menu',
    ));
}
add_action( 'init', 'register_my_menus' );

header.php

Top menu:

 <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>

Main menu:

 <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>

Here is the rendered output of both Top menu and Main menu

<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>

I'd also like to know if that's the best way to deal with bootstrap responsive menu (for the main menu'.

share|improve this question
    
Pretty sure item_location should not be top-men. –  s_ha_dum Feb 22 at 0:43
    
I corrected the typo, still doesn't work the way it should. I'd like to know what is wrong –  Bixal Feb 22 at 0:45
    
"I'd like to know what is wrong" -- I'd tell you if I knew. –  s_ha_dum Feb 22 at 1:22
    
The parameter you're looking for is theme_location, not item_location. –  sabreuse Feb 22 at 3:38
    
Oh, you saved me, I never realized where the error was. Thank you. Would you please add the answer to mark it as the best one? –  Bixal Feb 22 at 4:12

2 Answers 2

up vote 0 down vote accepted

Moving from comments: The parameter you're looking for is theme_location, not item_location.

share|improve this answer

Register your menu like this...

register_nav_menus( array(
        'primary1'   => __( 'Top primary menu First', 'ank' ),
        'primary2'   => __( 'Top primary menu Second', 'ank' ),
        'secondary' => __( 'Secondary menu in left sidebar', 'ank' ),
    ) );

and Use in code like this...

<?php wp_nav_menu( array( 'theme_location' => 'primary2' ) ); ?>

use theme_location instant-of item_location ......

share|improve this answer
    
I am aware of the __() function to make the word ready for translation, I don't need it in this specific theme, that's why. Thank you for your answer as well. –  Bixal Feb 22 at 5:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.