Problem with use meta in WP_QUERY
ImaggoDev opened this issue · 2 comments
ImaggoDev commented
Hi, I loved extended-cpts!
But i dont understand how to use meta keys in wp_query.
This is my code:
'site_filters' => [
'price_from' => [
'meta_key' => 'flat_price',
'meta_query' => [
'compare' => '>=',
'type' => 'NUMERIC',
],
],
]
If i go to url domain/flats/?price_from=200000 everything works. Query found only posts where field flat_price
>= $_GET['price_from'] , and this is awesome, but i have a problem with use this in WP Query via AJAX.
Code:
$args = array(
'post_type' => 'flat',
'paged' => $paged,
'price_from' => 200000,
);
$query = new \WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
...
}
}
and it doesnt work. Query find all flats also when flat_price
is for example 1000.
I tried change int to string in $args ['price_from' => '200000'
] but also doesnt work.
How to use meta keys in wp query and how to use when i have manyyy meta query data.
johnbillion commented
This should work. Let me look into it.
grzesiek1owline commented
Hi, @johnbillion did you have time to reproduce this error?