I'm quite new to WP theme development so I'm sorry if the answer for this question may seem obvious.

I'm developing a custom WordPress theme from scratch, and I'm stuck working on the menus. My header menu has some submenus that I'd like to style, but when I call the menu with the wp_nav_menu() function, the HTML output doesn't recognize them as submenus.

I mean, even if I built correctly the menus in the admin panel, the output I get is:

    <li>Item #1</li>
    <li>Item #2</li>
    <li>Item #3</li>
    <li>Item #4</li>
    <li>Item #5</li>
    <li>Item #6</li>

Item #4 and Item #5 are nested into a submenu under Item #3, for example, and I want them to be nested inside another ul, how they should be. I'm sure it's a theme related problem, because everything works well by switching to a default theme.

This is how I use the wp_nav_menu() function:

wp_nav_menu( array( 'theme_location' => 'header-menu',
                    'container_class' => 'navigator' ) )

Maybe I have to add something in functions.php, but I really don't know what.

Thank you all.

  • Can you show me how you use the wp_nav_menu() function.
    – Robbert
    Jun 9, 2015 at 14:37
  • Sure. I just set the theme_location and add a class to the container. wp_nav_menu( array( 'theme_location' => 'header-menu', 'container_class' => 'navigator' ) )
    – Oni-Link
    Jun 9, 2015 at 14:47
  • 1
    @Oni-Link Are they nested in the Menu or are they Children under pages? They need to be physically nested under Appearance -> Menu to show as children, it won't pull children automatically.
    – Howdy_McGee
    Jun 9, 2015 at 14:55
  • Are you using a custom walker? Are you sure the menus are correct in the backend?
    – s_ha_dum
    Jun 9, 2015 at 14:55
  • @Howdy_McGee, yes, they are physically nested under Appearance -> Menu.
    – Oni-Link
    Jun 9, 2015 at 14:58

2 Answers 2


In your array, have you tried setting depth to 0 or 2?

wp_nav_menu( array( 'theme_location' => 'header-menu',
                'container_class' => 'navigator',
                'depth' => 2) )

Where 0 should be the default and allow unlimited submenu, and 2 would allow one submenu. I am not sure how this would happen, but if it works, perhaps somewhere the default setting for depth was set to 1.


Apparently it was a menu registration issue. That menu was readable by WordPress, but not completely, because there were no positions available. I registered again the menu into my functions.php file and it worked. Thank you all anyway.

  • Hi - if you could accept your answer it'll mark the question as resolved and help us keep a tidy site. Thanks. Jul 22, 2016 at 16:43

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.