WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just noticed something weird I never saw before. I'm working on a project using WP 3.6.1. This project that has two different menus (actually, three, but that's not important). I'm calling them through the wp_nav_menu function.

I've done this kind of thing quite a few times now... but today is different. Today it doesn't work :(

My PHP code, placed in header.php, looks like this:

        <nav id="nav-menu-container">
            <div id="main-menu" class="main-menu menu clearfix">
                <?php wp_nav_menu('header_main'); ?>
            <div id="secondary-menu" class="secondary-menu menu clearfix">
                <?php wp_nav_menu('header_secondary'); ?>

The menu items are declared in functions.php and two different Menus are configured through the dashboard to show up in each location.

    if (function_exists('register_nav_menus')){
        register_nav_menu('header_main', 'Menú principal' );
        register_nav_menu('header_secondary', 'Menú secundario' );

But the first menu keeps on being printed in the two locations. As I said above, using two different menu is something that Ive done in the past, but today I don't see the error... and there is and error, as it is not working :S

Any ideas?

share|improve this question
up vote 2 down vote accepted

You're not calling wp_nav_menu() correctly.

You need to pass it an args array, and declare the theme_location key.

I'm assuming that, since you're passing a string rather than an array, wp_nav_menu() doesn't recognize the parameter, and is falling back to its default output:

  • the menu matching the ID, slug, or name given by the menu parameter, if that menu has at least 1 item;
  • otherwise, the first non-empty menu;
  • otherwise, output of the function given by the fallback_cb parameter (wp_page_menu(), by default);
  • otherwise nothing.

And you're seeing the first non-empty menu output in both locations.

Try this instead:

wp_nav_menu( array(
    'theme_location' => 'header_main'
) ):


wp_nav_menu( array(
    'theme_location' => 'header_secondary'
) ):
share|improve this answer
thanks, I was adding an answer, i found the problem :) thanks @chip – versvs Oct 2 '13 at 16:33

The problem is that wp_nav_menu requires as input an associative array and i'm entering a raw string.

This code may work everywhere.

    <nav id="nav-menu-container">
        <div id="main-menu" class="main-menu menu clearfix">
    <?php wp_nav_menu( array('theme_location' => 'header_main') ); ?>
        <div id="secondary-menu" class="secondary-menu menu clearfix">
            <?php wp_nav_menu( array('theme_location' => 'header_secondary') ); ?>

Sorry for the double post. It seems that the first menu was not appearing either, rather it was shown as a default option as no value was being passed at all.

share|improve this answer

Your Answer


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.