wp query on checkboxes value
-
Hello
I’m trying to make a search system based on checkboxes with wp_query. I want to implement the following search:
On a custom post-type “Houses”, look for houses whose area is:
less than 50m²
from 50 to 200m²
from 200 to 1000m²
superior to 1000m²Area values come from checkbox so the user can select one or more values
I made the following request but it does not work, I tried several combinations but it does not work. I get the message “0 result” while there are houses that match the search criteria.
Here is my code:<? Php $ 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); ?>Thanks for your help
The topic ‘wp query on checkboxes value’ is closed to new replies.