I need all products which have both categories. I am using a query below:
$args = array(
'post_type' => array('product', 'product_variation'),
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'shop', 'cat1' ),
'operator' => 'AND',
)
)
);
It's working correctly if cat1 category does not have any subcategory like cat1-1,cat1-2 etc. But when i made subcategory in backend of cat1 than result will give zero.
Query is same just no result if cat1 have subcategory.
Thanks