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

The following code does not produce a UL with ID of "nav". It just produces

<div class="menu"><ul>

This is the code:

wp_nav_menu( array( 'theme_location' => 'menu-1', 'container_id'    => 'nav'; 

According the WP Codex this should work. Why isn't it working?

WP version = 3.5


I now have:

wp_nav_menu( array( 'theme_location' => 'menu-1', 'items_wrap' => '<ul id="nav">%3$s</ul>', 'menu_id' => 'nav'));

but this doesn't work either.

share|improve this question
make sure your theme doesn't filter wp_nav_menu_args and override your settings. – Milo Jan 13 '13 at 3:35
@Milo. There is nothing in functions.php about this. – Steve Jan 13 '13 at 6:50

According to that Codex page, you need to use menu_id. container_id only effects the surrounding div.

share|improve this answer
I think you're right, but it is still producing <div class="menu"> – Steve Jan 11 '13 at 13:29
yeah according to codex, but's it's didn't work – GusDeCooL Jan 10 '15 at 15:21

The correct parameter for the ul is menu_id, and for the container container_id. But the ul works only if you pass …

'<ul id="%1$s" class="%2$s">%3$s</ul>'

… as items_wrap argument.

You can hard-code the value like this:

    array (
    'items_wrap'      => '<ul id="nav">%3$s</ul>'
    'theme_location' => 'top-menu'

See Any docs for wp_nav_menu's “items_wrap” argument?

share|improve this answer
Thanks @toscho, but this did not work either. – Steve Jan 13 '13 at 3:22
I now have wp_nav_menu( array( 'theme_location' => 'menu-1', 'items_wrap' => '<ul id="nav">%3$s</ul>', 'menu_id' => 'nav')); – Steve Jan 13 '13 at 3:23
@Steve Disable all plugins. You break something very badly. My solution works in all cases. – toscho Jan 13 '13 at 7:25
I have disabled all plugins, and the issue remains: output is <div class="menu"><ul> – Steve Jan 14 '13 at 11:41

As per my thinking menu-1 must be the ID of your menu. Please read about the parameters here and provide appropriate parameters.

According to me your code should be like

wp_nav_menu( array( 'menu' => 'menu-1', 'container_id'    => 'nav' ));
share|improve this answer
the menu parameter accepts an id from the database, not a CSS id. It is a CSS id I wish to assign to the UL. – Steve Jan 11 '13 at 13:30

This might be helpful, it was helpful for me to understand.

    <?php wp_nav_menu( array(
            'menu' => 0,
            'container' =>false,
            'menu_class' => 'nav',
            'echo' => true,
            'before' => '',
             'after' => '',
             'link_before' => '',
             'link_after' => '',
             'depth' => 0,
            'walker' => new description_walker())

That would give your menu's random id when you create them. Hope it was helpful not sure if i understood the question right.

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.