WordPress.org

Ready to get started?Download WordPress

Forums

Category based navigation menu (1 post)

  1. membrana
    Member
    Posted 5 years ago #

    Hi,
    I've been searching for some guidance on this subject but to no avail.
    I want to have an horizontal menu that displays all my parent categories, and when I click on one of those, below it displays another horizontal menu but with the child categories of the clicked one.
    The styling I think I can handle, but the php that would display the correct children upon clicking on the parent is what I cannot get right.

    I've found that this kind of menu is very used but with pages instead of categories. This is a code I found and I replaced every 'pages' for 'categories', but it didn't work (it was worth trying...).

    <ul id="nav">
         <?php wp_list_categories('depth=1&title_li='); ?>
    </ul>
    <?php if(wp_list_categories("child_of=".$post->ID."&echo=0")) { ?>
         <ul id="nav-sub">
              <?php wp_list_categories("title_li=0&child_of=".$post->ID."&sort_column=menu_order");?>
         </ul>
    <?php } ?>

    Any help will be appreciated.
    Thank you very much for your time!

    Martín.

Topic Closed

This topic has been closed to new replies.

About this Topic