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.

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

4 Answers 4


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

  • I think you're right, but it is still producing <div class="menu">
    – Steve
    Jan 11, 2013 at 13:29
  • yeah according to codex, but's it's didn't work
    – GusDeCooL
    Jan 10, 2015 at 15:21
  • this is the correct answer
    – Nate Beers
    Aug 4, 2017 at 16:03

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?

  • Thanks @toscho, but this did not work either.
    – Steve
    Jan 13, 2013 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, 2013 at 3:23
  • @Steve Disable all plugins. You break something very badly. My solution works in all cases.
    – fuxia
    Jan 13, 2013 at 7:25
  • I have disabled all plugins, and the issue remains: output is <div class="menu"><ul>
    – Steve
    Jan 14, 2013 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' ));
  • 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, 2013 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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