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 am using the menus API, and I want to switch to a different menu, but it is holding the first one for some reason

Here is my code

in functions.php

    add_action( 'init', 'register_my_menus',10 );

function register_my_menus() {

    register_nav_menu('main-navigation', 'Main Navigation');


Here is the code in my theme file (header.php)

    $args = array(
        'menu' => 'main-navigation',
        'container_id' => 'navigation',
        'fallback_cb' => 'wp_page_menu'
    wp_nav_menu($args); ?> 
share|improve this question
@Mild Fuzz: Can you post the code from your theme that calls wp_nav_menu to output to the web page so we can see what it it doing? – MikeSchinkel Oct 7 '10 at 17:52
the whole header.php file? – Mild Fuzz Oct 8 '10 at 10:13
up vote 2 down vote accepted

_Menus are somewhat confusing around there. Try this:

$args = array(
        'theme_location' => 'main-navigation',
        'container_id' => 'navigation',
        'fallback_cb' => 'wp_page_menu'

theme_location tries to display menu that is attached to this location. menu tries to display menu by slug/id (not location of menu, but actual menu that you create in admin area).

So you are mixing up location with menu slug, it gets confused and just serves first menu it can.

See wp_nav_menu() documentation for full description of logic behind it.

share|improve this answer
no effect, very odd – Mild Fuzz Oct 7 '10 at 15:55
Try it now. Rarst accidentally put a hyphen instead of an underscore for 'theme_location'. – John P Bloch Oct 7 '10 at 22:13
Oops, sorry. I hate such typos, they are hell to notice and fix. :( – Rarst Oct 8 '10 at 3:16
fix sorted it. Excellent – Mild Fuzz Oct 8 '10 at 14:06

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.