• Resolved swollenpickles

    (@swollenpickles)


    I’m struggling with this one. I have wordpress set up with two parent categories. Under these two parent categories there are a large number of child categories.

    I want to create two drop down lists, one for each parent category, that displays all the child categories within the parent. Make sense?

    Here’s what I have. Note. it doesn’t work! ??

    <?php _e('Categories:'); ?>
       <form action="<?php bloginfo('url'); ?>" method="get">
             <?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=4'); ?>
          <input type="submit" name="submit" value="view" />
       </form>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    First Question: Do you have posts in a category that is a child of category 8 on your blog? If not, wp_list_categories() will return “No categories”. Try adding a few posts to any of the child categories of cat #8 and you should see some change.

    Second question: Would you like a select element which is poulate with categories that a user can choose, submit a form and be redirected? If so, you might want to read up on wp_dropdown_categories().

    Please let me know if you still have questions,
    -Mike

    Thread Starter swollenpickles

    (@swollenpickles)

    Thanks for the reply. It looks like I’ve figured it out!

    Just to clarify in case anyone else is trying to do something similar, my category structure currently looks like this.

    Parent Category 1
    – cat 1 child 1
    – cat 1 child 2

    Parent Category 2
    – cat 2 child
    – cat 2 child 2

    In my dropdown menu I wanted to display the listing of all children under parent category 1 for example.

    Here’s what I’ve used.

    <form action="<?php bloginfo('url'); ?>" method="get">
             <?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=7'); ?>
          <input type="submit" name="submit" value="view" />
       </form>

    I think this post might help you… ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Creating drop down category menu displaying ‘child’ categories.’ is closed to new replies.