WP_Query min and max values

I’m building a houses class and i want to filter these houses with a query. But don’t get any results:

Example house:
Min price:10
Max price (field not required): empty

I’ve a price filter set on Min price 6 – Max price 15
I use this query to get the results, but it is not working.

new WP_Query([
‘post_type’ => ‘houses’,
‘meta_query’ => [
‘relation’ => ‘AND’,
[‘min_price’] => [
‘relation’ => ‘AND’,
[
‘key’ => ‘min_price’,
‘value’ => 6,
‘compare’ => ‘>=’
]
],
[‘max_price’] => [
‘relation’ => ‘AND’,
[
‘key’ => ‘max_price’,
‘value’ => 11,
‘compare’ => ‘

Read more here:: WP_Query min and max values

Leave a Reply

Your email address will not be published. Required fields are marked *