wp_nav_menu not displaying subcategories? (5 posts)

  1. alsd
    Posted 5 years ago #

    Maybe I am not fully understand how wp_nav_menu works. I thought if I add a parent category which has a number of subcategories I will be getting this:

    • Parent menu
      • Sub menu 1
      • Sub menu 2

    instead of

    • Parent menu
    • Sub menu 1
    • Sub menu 2

    I tried adding "depth" parameter:
    <?php wp_nav_menu( array( 'container_id' => 'quick-access', 'theme_location' => 'primary', 'depth' => 2, ) ); ?>

    Still I am not seeing a hierarchy. ?!

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    There is no hierarchy with custom menus. And there's no depth parameter for wp_nav_menu, either.


  3. alsd
    Posted 5 years ago #

    Hmmm, I saw this in the Default Usage:

    'depth' => 0,

    and quote Justin Tadlock (found the reference link in the codex link you provided):
    depth: How many levels the menu should display, which is useful for things like drop-down menus. This is set to 0 (any level) by default.

  4. alsd
    Posted 5 years ago #

    OK, I found the problem. It does work.

    Once the menu added to menu area, you need to drag the menu bar, up/down for horizontal position, left/right for hierarchy. "'depth' => 2" prevent user to use the 3rd level.

  5. vaseemansari
    Posted 4 years ago #

    Hello Dear

    i have a query and i know that you know the answer of this
    i am using wp nav menu to show 6 navigation menu in header here

    Now i want when user clicks on any item(post,page,category,tag) in sub menu then the left sidebar will show all the submenus of that parent.

    My question is similar to this thread

    Root Menu
    Sub menu 1
    Sub menu 2 (clicked)

    My sidebar will show only child sub menus of clicked root menu
    Sub menu 1
    Sub menu 2 (clicked)

    Waiting for your answer.
    Vaseem Ansari

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.