0

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?

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.