Why is my WP_Query not working when tax_query terms are an array?

When you’re doing a tax_query or meta_query in a WP_Query, you always have to use a nested

array( array() );

just see the following example for an explanation and pay attention to the relation argument.

$packages = new WP_Query( array(
    'post_type' => 'vamos-cpt-packages',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'vamos-holiday-types',
            'field'    => 'slug',
            'terms'    => array( 'activity-holidays' )
        ),
        array(
            'taxonomy' => 'vamos-holiday-types',
            'field'    => 'id',
            'terms'    => array( 103, 115, 206 ),
            'operator' => 'NOT IN'
        )
    )
) );

Leave a Comment