WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding Multiple Category Dropdowns (7 posts)

  1. dmx09
    Member
    Posted 3 years ago #

    Hi,

    I'm building a site that will require multiple dropdowns, each displaying a different category like so:

    Genre (Dropdown 1)
    Rock
    Alternative
    etc

    Tempo (Dropdown 1)
    Fast
    Slow
    etc

    I can easily display 'All' categories using the following: (taken from the codex)

    <?php wp_dropdown_categories('show_count=1&hierarchical=1'); ?>

    I'm just not sure how I can have multiple instances, each displaying a different category..

    This doesn't seem to work, when I add &cat=26 at the end of the line of code:

    <?php wp_dropdown_categories('show_count=1&hierarchical=1&cat=14'); ?>

    <?php wp_dropdown_categories('show_count=1&hierarchical=1&cat=26'); ?>

    Any suggestions would be most appreciated!

  2. MULTIDOTS
    Member
    Posted 3 years ago #

    Hi dmx09,
    for this purpose you can use
    <?php wp_dropdown_categories('show_count=1&hierarchical=1&child_of=25');?>

  3. dmx09
    Member
    Posted 3 years ago #

    That works a treat, many thanks!

    At the moment it only displays the categories which have posts attached to them, is there a way to show all categories regardless of whether there are associated posts?

    I've added &show_option_all but it still only shows populated categories.

    <?php wp_dropdown_categories('show_count=1&hierarchical=1&child_of=26&show_option_all');?>

  4. extatix
    Member
    Posted 3 years ago #

  5. dmx09
    Member
    Posted 3 years ago #

    Thanks, thats where I got the &show_option_all code from.
    I'll have another look, maybe I missed something.

  6. extatix
    Member
    Posted 3 years ago #

    'hide_empty' => 1,

  7. dmx09
    Member
    Posted 3 years ago #

    Fantastic, many thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic