I am creating a search system with data from front-end checkboxes and wp query on a custom post-type. But the query does not work, "0 item found".
I created a search form where users can search for an area according to several criteria: less than 50 m² from 50 to 200 m² from 200 to 1000m² greater than 1000 m² the search criteria values come from front-end checkboxes. And I have a custom post-type called "Houses" on the back end. I made a query with wp query but it does not work, it displays 0 result while there are posts that meet the search criteria.
$ args = array (
‘post_type’ => ‘Houses’,
‘posts_per_page’ => -1,
‘meta_query’ => array (
‘relation’ => ‘OR’,
array (
‘key’ => ‘wpcf-area’,
‘value’ => 50,
‘type’ => ‘numeric’,
‘compare’ => ‘<‘
),
array (
‘key’ => ‘wpcf-area’,
‘value’ => array (50, 200),
‘type’ => ‘numeric’,
‘compare’ => ‘BETWEEN’
),
array (
‘key’ => ‘wpcf-area’,
‘value’ => array (200, 1000),
‘type’ => ‘numeric’,
‘compare’ => ‘BETWEEN’
),
array (
‘key’ => ‘wpcf-area,
‘value’ => 1000,
‘type’ => ‘numeric’,
‘compare’ => ‘>’
)
)
);
$ query = new WP_Query ($ args);
I'm getting "0 result" while there are posts that meet the search criteria. Thank you
Aucun commentaire:
Enregistrer un commentaire