I'd like to have separate meta_query
arguments according to the post type.
For example, I'd like to query t-shirts
that have a green collar or dress-shirts
that have a green inner-lining, right now I only do a single post type check where I check for t-shirts
and dress-shirts
and I separately check for the meta values which mean that it will also show different combinations such as t-shirts
that have a green inner-lining
$query = new WP_Query(array(
'post_type' => array('t-shirts', 'dress-shirts'),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'collar',
'value' => 'green',
),
array(
'key' => 'inner-lining',
'value' => 'green',
)
),
));
How can I set it up to work with two different args, one if the post type is t-shirts
and a seperate args if the post type is dress-shirts
which would look something like:
$query = new WP_Query(
array(
array(
'post_type' => array('t-shirts'),
'meta_query' => array(
array(
'key' => 'heal',
'value' => 'green',
)
),
),
array(
'post_type' => array('dress-shirts'),
'meta_query' => array(
array(
'key' => 'sleeve',
'value' => 'green',
)
),
),
)
);
Doing two separate queries won't work as it will mess up pagination.