I have a menu that looks like this:

enter image description here

Women and Men har the top level menu items while the lower nagivation menu items are the children.

The menu structure looks like this:

Women
  New styles
  Clothes
    Jeans
    Dresses
    Shirts
  Underwear
Men
  New styles
  Clothes
    Jeans
    T-shirts
    Shirts
  Underwear

If I click on "Women", children of the Women menu item will be shown in the lower navigation. If I click on "Men", children of the Men menu item will be shown in the lower navigation.

Displaying the top level menu items (Women and Men) is easy. I'm doing it like this:

<?php wp_nav_menu(
    array(
        'theme_location' => 'main-menu', // Menu ID registered in functions.php
        'walker' => new Custom_Primary_Nav_Menu(),
        'depth' => '1', // Show levels. (0 = all)
        'container' => 'nav', // What container element to wrap the nav with
        'fallback_cb' => false // If the menu doesn't exists, the navigation will fall back to 'wp_page_menu'
    )
); ?>

However displaying the children are not so easy. The 'depth' parameter is not enough.

I need to display menu items from 2nd level to infinity thereby excluding the top level items.

How can I do this?

I wan't to use only 1 menu for everything if possible so that it's easy to show a mobile navigation with everything in it.

  • What does your Custom_Primary_Nav_Menu walker do? – Jacob Peattie Dec 7 at 11:36
  • 1
    It's a 1:1 copy of the core nav walker with the only exception of an added div used for expanding/contracting submenus in the mobile nav using javascript. – Skovsgaard Dec 7 at 12:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.