WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to wordpress and PHP Im trying to build a site that the user can select a destination so I did this by creating categories (country) subcategories (state) sub sub category (city) and I want to split them into 3 dynamic drop down menus when you select country the state automatically populates according to the parents then the same with city, then it will do a search for destinations (posts) attached to the selections.

So far I have one dropdown working but is listing all (parent, children, grandchildren) categories and doing the search correctly. how can I split them?

<?php $thecategories = array(
        'show_option_all'    => '',
        'show_option_none'   => '',
        'orderby'            => 'ID', 
        'order'              => 'ASC',
        'show_count'         => 0,
        'hide_empty'         => 1, 
        'child_of'           => 0,
        'exclude'            => '',
        'echo'               => 1,
        'selected'           => 0,
        'hierarchical'       => 0, 
        'name'               => 'cat',
        'id'                 => '',
        'class'              => 'postform',
        'depth'              => 0,
        'tab_index'          => 0,
        'taxonomy'           => 'category',
        'hide_if_empty'      => false
    ); ?>

<form action="<?php bloginfo('url'); ?>" method="get">
  <?php wp_dropdown_categories( $thecategories ); ?>
  <input type="submit" name="submit" value="view" />
share|improve this question
up vote 0 down vote accepted

I found a solution for this in case someone else has this issue, there is a plugin that can help achieve this it is called Category Ajax Chain Selects http://wordpress.org/extend/plugins/category-ajax-chain-selects/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.