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 have been pouring through the code trying to find out how the navigation menu is actually built. In my header I see:

< nav id="site-navigation" class="main-navigation" role="navigation">
    < h3 class="menu-toggle">Menu< /h3>
    < a class="assistive-text" href="" title="Skip to content">Skip to content< /a>
    < div class="menu-main-menu-container">
        < ul id="menu-main-menu" class="nav-menu">
            < li id="menu-item-22" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22">< a href="">< /a>
             < ul class="sub-menu">
               < li id="menu-item-314" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-314">< a href="">< /a>< /li>
               < li id="menu-item-123" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-123">< a href="">< /a>< /li>
            < /ul>
          < /li>
         < li id="menu-item-316" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-316"><a href=""></a>
      < ul class="sub-menu">

I'm mostly trying to figure out where the sub-menu comes from. I need to add a div inside the sub menu for some extra styling.

share|improve this question
up vote 2 down vote accepted

The code in question is in header.php, line 45.

<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>

This is the Codex reference to this function: wp_nav_menu.

From my experience, and some googling, this previous answer has the answer you're looking for.

If possible, would just adding a class to the sub-menus do the trick instead of adding a div? If so you should be able to just copy and paste the code from the above linked answer and then target the elements with CSS to get the effect you're after.

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.