WordPress.org

Ready to get started?Download WordPress

Forums

How to make output of a select list be dependant on parent list? (1 post)

  1. grundizer
    Member
    Posted 1 year ago #

    I have two arrays that have a parent category and sub category each appear in a select list, how do I make the sub category show items only from its parent category?

    <?php $carMakes = array(
     'show_option_all'    => '',
     'show_option_none'   => ('All Makes'),
     'orderby'            => 'ID',
     'order'              => 'ASC',
     'show_count'         => 0,
     'hide_empty'         => 1,
     'child_of'           => 25,
     'exclude'            => 0,
     'echo'               => 1,
     'selected'           => 0,
     'hierarchical'       => 0,
     'name'               => 'cat',
     'id'                 => '',
     'class'              => 'postform',
     'depth'              => 0,
     'tab_index'          => 0,
     'taxonomy'           => 'category',
     'hide_if_empty'      => false
    ); ?>
    <?php $carModels = array(
     'name'               => 'subcat',
     'hierarchical'       => 1,
     'parent'             => get_cat_id('model'),
     'show_option_none'   => ('All Models'),
     'hide_empty'   => 0  );
    ?>
    <?php wp_dropdown_categories($carMakes); ?>
    <?php wp_dropdown_categories($carModels); ?>

    need to only show car models that belong to car makes for example

    Make=Toyota  Model=Supra
                 Model=Corolla
                 Model=Tundra

Topic Closed

This topic has been closed to new replies.

About this Topic