php - Wordpress - working search form with multiple taxonomies
one text
I need help with filtering Woocommerce products by taxonomy terms:
<form method="GET" action="<?php echo esc_url( home_url() ); ?>">
<input type="hidden" value="product" name="post_type">
<div class="select-wrap">
<label>Locations</label>
<select class="select--field">
<option selected disabled>Select location</option>
<?php
$tax_terms = get_terms( 'location', array( 'hide_empty' => '0' ) );
foreach ( $tax_terms as $tax_term ) :
echo '<option value="' . $tax_term->name . '">' . $tax_term->name . '</option>';
endforeach;
?>
</select>
</div>
<div class="select-wrap">
<label>Sport services</label>
<select class="select--field">
<option selected disabled>Select sport service</option>
<?php
$tax_terms = get_terms( 'sport', array( 'hide_empty' => '0' ) );
foreach ( $tax_terms as $tax_term ) :
echo '<option value="' . $tax_term->name . '">' . $tax_term->name . '</option>';
endforeach;
?>
</select>
</div>
<div class="select-wrap">
<label>Services</label>
<select class="select--field">
<option selected disabled>Select service</option>
<?php
$tax_terms = get_terms( 'service', array( 'hide_empty' => '0' ) );
foreach ( $tax_terms as $tax_term ) :
echo '<option value="' . $tax_term->name . '">' . $tax_term->name . '</option>';
endforeach;
?>
</select>
</div>
<button type="submit" class="search-btn btn--lg">Search</button>
</form>
Results from this form are products with no selected terms.. example.com/?post_type=product
. It doesn't take into account selected terms. I will very appreciate, if someone can help with this. Thanks a lot!