• Resolved harshclimate

    (@harshclimate)


    I’m creating a theme where I’m using two menus in the header. One menu is called “Primary” and the other is called “Secondary”. After I’ve registered the two menus in functions like so:

    function azb_menu() {
       register_nav_menus(
    	array(
    	  'primary' => __( 'Primary Menu' ),
    	  'secondary' => __( 'Secondary Menu' )
    	)
       );
    } add_action( 'init', 'azb_menu' );

    then called it in my header.php like so:

    <div class="primary">
       <?php wp_nav_menu( array( 'theme_location' => 'Primary Menu' ) ); ?>
    </div>
    <div class="secondary">
       <?php wp_nav_menu( array( 'theme_location' => 'Secondary Menu' ) ); ?>
    </div>

    I get duplicated “Sample Page” in both menus. When I looked at the source I found that the html is exactly the same. This is the source:

    <div class="primary">
       <div class="menu">
        <ul>
          <li class="page_item page-item-2"><a href="https://azb2.local/sample-page/">Sample Page</a>
          </li>
        </ul>
      </div>
    </div>
    <div class="secondary">
       <div class="menu">
        <ul>
          <li class="page_item page-item-2"><a href="https://azb2.local/sample-page/">Sample Page</a>
          </li>
       </ul>
      </div>
    </div>

    Not sure what in heck is going on, but I can’t figure out why they are the same, and why, when I add new items to the menu they aren’t showing up!

    • This topic was modified 3 years, 6 months ago by harshclimate.
    • This topic was modified 3 years, 6 months ago by bcworkz.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Use the registered array key for the theme location arg, not the value
    wp_nav_menu( array( 'theme_location' => 'primary', ) );

    The value is for display purposes in the UI, the key is like the location’s slug.

    Thread Starter harshclimate

    (@harshclimate)

    Sigh. It doesn’t help that I’ve been starring at this stuff for hours upon hours. Sometimes even the simplest things get me all in a kerfuffle. Thanks, BC – Sure do appreciate you.

    Moderator bcworkz

    (@bcworkz)

    I know how that goes. Nothing like an extra set of eyes to spot a glitch!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘My navigation menus are stuck!’ is closed to new replies.