Answer the question
In order to leave comments, you need to log in
How to sort/filter a field by custom fields?
Interested in how you can sort posts by arbitrary fields ("city" and "rating").
Ideally, the filter should consist of two select lists: city selection and sorting by rating.
Example:
I suspect that you need to somehow add the $_GET function and something from this opera:
$args = array(
'meta_key' => 'color',
'meta_value' => 'blue'
);
$query = new WP_Query( $args );
But I can’t figure out how to connect it or insert it into the form of the mind:
<form class='post-filters'>
<select name="select_city">
<?php ?>
</select>
<select name="order_by_rating">
<?php ?>
</select>
<input type='submit' value='Filter!'>
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question