I have this WP_Query:
new WP_Query( array( 'post_type' => 'product_variation', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( 'archive', 'membership' ), 'operator' => 'NOT IN', ), ), 'fields' => 'ids', ) );
The problem is, that the
product_cat taxonomy is set on the parent products, not the variations. Meaning, I need to get all the variations whose parents are not in the specified categories, or in other words: get child posts but run the tax query on the parent posts.
I know this can be achieved with MySQL, but I was wondering if there's a clean way of doing it with WP_Query.