0

So my main goal is to create 3 drop-down category options to run a search. It's for a car website, so I have 3 parents, "Make", "Model", and "Year"

At the moment I have the following code

<?php $args = array('show_option_none' => 'Make', child_of => 5,hide_empty => '0',exclude => '0'); ?>
<b>Make  </b><?php wp_dropdown_categories($args); ?>

<?php $args2 = array('show_option_none' => 'Model', hide_empty => '0',exclude => '0'); ?>
<b>Model  </b><?php wp_dropdown_categories($args2); ?>

<?php $args3 = array('show_option_none' => 'Year', hide_empty => '0',exclude => '0'); ?>
<b>Year  </b><?php wp_dropdown_categories($args3); ?>

I plan on creating an if statement for the "Models" so it changes based on the "Make" selection.

http://i.imgur.com/KExUpGw.png

How can I remove grandchildren from the "Make" drop-down? At the moment it shows the Car makers and the models underneath.

Is there a better way to do this?

1

To remove grand-children:

<?php $args = array(
    'show_option_none' => 'Make', 
    child_of => 5,
    hide_empty => '0',
    exclude => '0',
    hierarchical => 1,
    depth => 1
    ); ?>
<b>Make  </b><?php wp_dropdown_categories($args); ?>

You need to add the hierarchical and depth parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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