Show all menu levels except top level. How to exclude top level of a menu?

enter image description here

I have a menu that looks like this:

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.

Read more here:: Show all menu levels except top level. How to exclude top level of a menu?

Leave a Reply

Your email address will not be published. Required fields are marked *