Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am currently developing a wordpress theme that has a tricky main navigation menu.

The problem I am stuck with is that I am looking for a special print of the submenu. Here is the html I am trying to achieve in my theme:

<nav role="navigation">
    <ul id="main-menu" class="nav top-nav clearfix">
        <li id="menu-item-1" class="menu-item"><a href="#">Menu Item 1</a></li>
        <li id="menu-item-2" class="menu-item"><a href="#">Menu Item 2</a></li>
        <li id="menu-item-3" class="menu-item"><a href="#">Menu Item 3</a></li>
    </ul>
    <ul id="submenu-for-menu-item-1" class="sub-menu">
        <li class="menu-item"><a href="#">Submenu Item 1.1</a></li>
        <li class="menu-item"><a href="#">Submenu Item 1.2</a></li>
        <li class="menu-item"><a href="#">Submenu Item 1.3</a></li>
    </ul>
    <ul id="submenu-for-menu-item-2" class="sub-menu">
        <li class="menu-item"><a href="#">Submenu Item 2.1</a></li>
        <li class="menu-item"><a href="#">Submenu Item 2.2</a></li>
        <li class="menu-item"><a href="#">Submenu Item 2.3</a></li>
    </ul>
    <ul id="submenu-for-menu-item-3" class="sub-menu">
        <li class="menu-item"><a href="#">Submenu Item 3.1</a></li>
        <li class="menu-item"><a href="#">Submenu Item 3.2</a></li>
        <li class="menu-item"><a href="#">Submenu Item 3.3</a></li>
    </ul>
</nav>

What's the best approach to achieve that?

share|improve this question
    
For any serious menu output customization you are probably looking for extending Walker_Nav_Menu class, but you probably won't get ready-made answer because most people like to do that like they like a headache. :) –  Rarst Nov 19 '13 at 10:46
    
That's very useful! Thanks a lot! Your answer combined with a better google search lead me to this: shinraholdings.com/62/custom-nav-menu-walker-function/… Thanks again! I will answer my question when I get my code done. –  Dragos Rizescu Nov 20 '13 at 19:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.