I'm facing a rather strange issue when attempting to pass in four different meta_query values to my WP_Query.
Find below an example of my WP_Query search. Please bear in mind, if I remove and test each of these meta_query on there own, they work fine. It's just when they are being passed in as four do I not get any results. Even if I leave the values blank I still receive no posts in my query!
$v_args = array( 'post_type' => 'loads_available', 's' => "Post Name", 'meta_query' => array( array( 'key' => 'type_of_load', 'value' => "Frozen", 'compare' => '=', ), array( 'key' => 'number_of_pallets', 'value' => 2, 'compare' => '>=', 'type' => 'NUMERIC' ), array( 'key' => 'type_of_trailer_required', 'value' => "Trailor", 'compare' => '=', ), // ^ problem array( 'key' => 'euro_pallets', 'value' => "Yes", 'compare' => '=' ) ) ); $loadsAvailableQuery = new WP_Query( $v_args );
Now I would just like to make it clear, these meta_query values work fine on a individual basis, it's just when I start trying to use them in conjunction with each other for example.
Search query would be:
Post Name: "Post Name" Type of Load: "Frozen" Number of Pallets: 5 Type of Trailor Required: "Trailor" Euro Pallets: "Yes"
This would not give me any results, even though I am sure there is posts meeting the criteria. It's feels like I could be missing something in the Query, I read about use relation but that defaults to "OR" - which I believe would be the correct value here.
Are there any common misconceptions or obvious flaws in my code that I'm not quite seeing here?
Many thanks for the responses.