I’m working on a custom filtering to pass the parameters to the page url when user selects a value and clicks the search button. However I can’t get the proper output parameters.
in order for the filtering to work I need a format which looks something like this:
shop/?filter_tyre-width=22
What I get currently looks like this:
shop/?tyre_width=22
How do I slot in the prefix filter_
right after the ?
symbol?
<?php
$terms_width = get_terms("pa_tyre-width");
$terms_height = get_terms("pa_aspect-ratio");
$filter_width = isset( $_GET['tyre_width'] ) ? esc_attr( $_GET['tyre_width'] ) : '';
$filter_height = isset( $_GET['aspect-ratio'] ) ? esc_attr( $_GET['aspect-ratio'] ) : '';
$new_link = add_query_arg( 'filtering', '1', $form_action );
echo $new_link;
echo '<form method="get" action="' . $new_link . '" class="col-md-12 clearfix">';
echo '
<div class="col-md-3">
<label for="">Width</label>
<div class="input-group select-large">
<select id="tyre_width" name="tyre_width">
<option>Select Width</option>
';
foreach ( $terms_width as $term_width ) {
echo '
<option value="' . $term_width->name . '"> ' . $term_width->name . '</option>
';
}
echo '</select></div></div>';
echo '
<div class="col-md-3">
<label for="">Height</label>
<div class="input-group select-large">
<select id="aspect-ratio" name="aspect-ratio">
';
foreach ( $terms_height as $term_height ) {
echo '
<option value="' . $term_height->name . '"> ' . $term_height->name . '</option>
';
}
echo '</select></div></div>';
echo '
<div class="col-md-3">
<div class="input-group search-btn">
<label for="submit">Start Search!</label>
<input type="submit" placeholder="Go" value="Search">
</div>
</form>';