Give help. Get help.

  • # May 20, 2013 at 5:29 pm

    Hi all

    I have set up a wp_nav_menu in WordPress. I have 2 parent categories, with 2 sub-categories each, so this produces a nested list.

    My current code to call this menu is…

    < ?php wp_nav_menu(
    ‘theme_location’ => ‘shop-categories’,
    ‘container’ => ‘nav’,
    ‘container_class’ => ‘shop-cat’
    ); ?>
    … which outputs this…

    (I have simplified the code so you just get an idea of the markup)

    Now I would like to output this…

    …is this possible to do dynamically? Or will it be better to do this manually? I have had a look around but couldn’t find any help on this.

    Any help appreciated.

    # May 20, 2013 at 5:35 pm

    You will need to extend Walker Class for wp_nav_menu():

    # May 20, 2013 at 6:09 pm

    Thanks for pointing me in the right direction.

    Looking at that code…pretty complex for a PHP novice!

    I may consider a manual solution as I can see the optgroup labels being a problem.

    # May 21, 2013 at 4:02 pm

    Sorry I was using the wrong function.

    wp_dropdown_categories was the function I was looking for which does this by default.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.