I have Three Fields in the form, first is Default WordPress Category and two custom taxonomies. When I try to Search a Single field "Selected Attribute" Works Correct but on category, selection taxonomy selected value unselect and do not show selected attribute. Below is the Code:
<form method="get" action="<?php echo get_site_url(); ?>" class="">
<!--categories-->
<!--default categories dropdown-->
<?php
$categoryselected = get_queried_object();
$categories = wp_dropdown_categories(array(
'taxonomy' => 'category',
'post_type' => 'post',
'show_option_all' => 'All Categories',
'orderby' => 'name',
'echo' => 1,
'select' => $cat,
'name' => 'cat',
'hierarchical' => true,
'class' => 'cat-dropdown form-control',
'id' => 'custom-cat-drop',
'value_field' => 'term_id',
'post_status' => 'publish',
'no_found_rows' => true,
/*when I selected this category other fields selected attributes not working*/
'selected' => $categoryselected->term_id
));
?>
<!--location-->
<?php
$current_category = get_queried_object();
wp_dropdown_categories(array(
'taxonomy' => 'location',
'post_type' => 'post',
'show_option_all' => 'Select Location',
'orderby' => 'name',
'echo' => 1,
'name' => 'location',
'hierarchical' => true,
'class' => 'cat-dropdown form-control',
'id' => 'custom-cat-dr
'value_field' => 'name',
'post_status' => 'publish',
'no_found_rows' => true,
/*in Single Field Search it work correctly but on above category selection attribute not worked*/
'selected' => $current_category->name
));
?>
<!--job_type-->
<?php
$current_category = get_queried_object();
wp_dropdown_categories( array(
'taxonomy' => 'job_type',
'post_type' => 'post',
'show_option_all' => 'Job Type',
'option_none_value' => '',
'echo' => 1,
'name' => 'job_type',
'id' => 'custom-cat-drop',
'select' => $cat,
'value_field' => 'name',
'class' => 'cat-dropdown form-control',
'post_status' => 'publish',
'hierarchical' => true,
'no_found_rows' => true,
/*in Single Field Search it work correctly but on above category selection attribute not worked*/
'selected' => $current_category->name
) );
?>
<input type="hidden" value="post" name="post_type" />
<button type="submit" class="btn-search">Find Job <i class="fa fa-search"></i></button>
</form>
selected
attribute is the same for each of three queries. And it's impossible to say what is its value because it is unknown in which template file the code resides.