I assume that your posts are having make
and model
as a Custom Fields and you want to retrieve all those posts which are matching both the passed value for make
and model
Custom Fields. If that is the case then your code seems to be correct. It might be possible that there is no matching post is there so you are not getting any result. But if you wants to retrieve all the posts which are either matching make
or model
Custom Fields value then you might need to add relation
parameter in meta_query
as the default value for the relation
parameter is AND
. Below is how you can add relation
parameter with the OR
in code.
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'make',
'value' => $make,
'compare' => '='
),
array(
'key' => 'model',
'value' => $model,
'compare' => '='
)
)
Check the following link get more details on using meta_query
in WP_Query
. https://codex.wordpress.org/Class_Reference/WP_Query