how to get listings using meta query relation argument
-
I am trying to show some listings using wp_query and using meta_query.
but I feel that sometimes the results are not accurate. I don’t know where’s the mistake$resultsargs = array( 'post_type' => 'listings', 'posts_per_page' => 3, 'meta_query' => array( 'relation' => 'OR', 'meta_query' => array( array( 'key' => 'type_of_vehicle_c', 'value' => $splittedNumbers, 'compare' => '=', ), array( 'relation' => 'AND', // only 'color' OR 'price' must match array( 'key' => 'interests_c', 'value' => $interestsNumbers, 'compare' => '=', ), array( 'key' => 'musthave_c', 'value' => $musthaveNumbers, 'compare' => '=', ) ) ) ) );
NOTE: the keys ‘musthave_c’ and ‘interests_c’ are stored as serialized data in the database. and their values are returned as arrays in variables ‘$musthaveNumbers’ and ‘$interestsNumbers’
after my selections it will show me the listings who have my selected values but it will also show me the listings who dont have my selected values
like if the $interestsNumbers found and no values for $musthaveNumbers found then it will also show me some listings who just have $interestsNumberI just want to show listings that contain any of the values provided in the array but should have both $interestsNumbers and $musthaveNumbers found atleast 1 matching value.
can anyone help?
Thanks
- The topic ‘how to get listings using meta query relation argument’ is closed to new replies.