I have an issue with a WP_Query for a site I’m building which has me stumped.
This works as expected:
$package_args = array(
'post_type' => 'vamos-cpt-packages',
'tax_query' => array(
'taxonomy' => 'vamos-holiday-types',
'field' => 'slug',
'terms' => 'activity-holidays'
)
);
$packages = new WP_Query($package_args);
var_dump($packages);
But when the terms are an array:
$package_args = array(
'post_type' => 'vamos-cpt-packages',
'tax_query' => array(
'taxonomy' => 'vamos-holiday-types',
'field' => 'slug',
'terms' => array('activity-holidays')
)
);
$packages = new WP_Query($package_args);
var_dump($packages);
It doesn’t! I get no posts returned. Can anyone explain this?
Cheers
Kevin
When you’re doing a
tax_query
ormeta_query
in aWP_Query
, you always have to use a nestedjust see the following example for an explanation and pay attention to the
relation
argument.