Answer the question
In order to leave comments, you need to log in
How to implement post filter using select?
I have a category where posts are displayed. Select pages with city districts are set on the pages, it is necessary that when choosing a district, posts are displayed only with this district.
Each post has additional fields with the help of ACF where these areas are indicated.
The question is how to display these same posts using select ?
Answer the question
In order to leave comments, you need to log in
Create a select that, when changed, will add a disctict parameter to the get url, for example, with a district number of 1,2,3
<select onchange="location=value">
<option value="" selected="selected">Выбрать район</option>
<option value="?district=1">Район 1</option>
<option value="?district=2">Район 2</option>
<option value="?district=3">Район 3</option>
</select>
$disctricts = new WP_Query(['post_type' => 'disctricts', 'meta_key' => 'disctrict', 'meta_value' => $_GET['disctrict']]);
// далее удобным вам способом выводите районы из массива $disctricts
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question