0

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" />
</form>

1 Answer 1

0

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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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