Tax query with `AND` operator does not work with WooCommerce category
In WooCommerce categories, I have Cat 1 (slug is cat-1) and Cat 2 (slug is cat-2). I added many products which belong to both categories. But when i want to query those products, no products found:
$q = new WP_Query([ 'post_type' => 'product', 'post_status' => 'publish', 'tax_query' => [ [ 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => ['cat-1', 'cat-2'], 'operator' => 'AND' ] ] ]); var_dump($q->posts); // empty array
Am I missing something?
The weird thing is when i tested the query with the default
post post type and the
category taxonomy, everything worked fine.