This is a pretty simple and infuriating question. Can anyone help me understand why the tax_query
fields below end up with different results? As far as I can tell, the only difference is the AND
relation (which should not be necessary but doesn’t hurt) in the second tax_query
. Anyone? I saw this post which may be having the same problem, but the answer didn’t do the trick.
(To be specific, these are the var_export
results of query->get('tax_query')
in pre_get_posts
.)
No products returned (incorrect result):
array (
0 =>
array (
'taxonomy' => 'product_cat',
'terms' =>
array (
0 => 'Gift Cards',
),
'field' => 'slug',
'operator' => 'NOT IN',
),
1 =>
array (
'taxonomy' => 'product_tag',
'terms' =>
array (
0 => 'Construction:knit',
),
'field' => 'slug',
),
)
Three products returned (the correct result):
array (
0 =>
array (
'taxonomy' => 'product_cat',
'terms' =>
array (
0 => 'Gift Cards',
),
'field' => 'slug',
'operator' => 'NOT IN',
),
1 =>
array (
'relation' => 'AND',
0 =>
array (
'taxonomy' => 'product_tag',
'terms' =>
array (
0 => 'Construction:knit',
),
'field' => 'slug',
),
),
)