I’m trying to make a custom search form where each post has custom meta data. When I filter by two key values I can get the results. But when I add a third array, amenities, the results don’t appear.
Is this too complex of a query?
Here is my query argument:
$args_listings = array(
'cat' => 'listings',
'meta_query' => array(
array(
'key' => 'neighborhood',
'value' => $neighborhoodlist,
),
array(
'key' => 'bedrooms',
'value' => $bedroomnum,
),
array(
'key' => 'amenities',
'value' => $amenitieslist,
),
),
);
Eventually I would like to have more filters related to the search.
Hi mrdirby,
have you tried using the ‘relational’ query to set this?
$meta_query_args = array(
'relation' => 'OR', // Optional, defaults to "AND"
array(
'key' => '_my_custom_key',
'value' => 'Value I am looking for',
'compare' => '='
)
);
$meta_query = new WP_Meta_Query( $meta_query_args );
I hope to have helped