My solution to this ended up splitting this into 2 queries:
- Get the IDs of all the parent products I want to ignore
-
Get all the variations that don’t a post_parent from that list of IDs
$archived_products = wc_get_products( array( 'type' => array( 'variable', 'variable-subscription' ), 'paginate' => false, 'limit' => -1, 'category' => array( 'archive', 'membership' ), 'return' => 'ids', ) ); $my_query->set( 'post_parent__not_in', $archived_products );
Related Posts:
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- How to combine tax_query and date_query in WordPress
- Find all product that contain terms with %keywords% in WP_Query
- Tax Query on product_cat using NOT IN as operator does not exclude that category
- Select multiple categories with is_tax
- Woocommerce orderby rand with tax_query not random
- WordPress tax_query “and” operator not functioning as desired
- How to query only for products with status “in stock” in WooCommerce? [closed]
- Escaping WP_Query tax_query when term has special character(s)
- Tax_query terms ID’s using variable
- WP_Query for WooCommerce Products
- Woocommerce query by price range and custom meta key
- Retrieve products with specific attribute and in category – woocommerce
- how to retrieve specific product attribute value in an sql query?
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- How to extend tag and category “Related Posts” query to custom post_type if the first 2 terms have no posts
- Using tax_query reverses my post_type argument in a custom WP_Query
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Display featured products through custom loop in WooCommerce 3 [closed]
- tax_query shows no results if nothing is selected
- get complex results set according to category structure
- Get product list of given category
- WP_Query tax_query problem
- How to exclude products by tag from woocommerce shop page?
- WooCommerce Only OnSale Products Loop Snippet [closed]
- WP_Query, tax_query and term_meta: How to?
- Empty tax_query array returns an empty array
- How can i simulate “taxonomy__in” in query?
- tax_query: Order by slug?
- merge two query arguments into one WP_Query call
- Woocommerce returns Product post_status as published even tho it is in status draft
- showing all search result in one template
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Get all products which have both product category
- Populate tax_query terms parameter with post term
- Woocommerce query all products and categories
- Fastest way of counting posts of a custom post type in a specific taxonomy term?
- Take all produts by category
- How to get all product attributes for filters in WooCommerce?
- Is it a good idea to improve meta query performance by adding tax query?
- WP_Query | Tax_Query Relation | Unable to use ‘OR’ as it then allows all products, help me finish my query?
- Having trouble with WooCommerce Storefront child theme single.php “related posts” modification [closed]
- Out Of memory issue on post per page parameter
- Hiding taxonomies with no children WP_Query & tax_query
- Query with meta_query and tax_query together not working properly
- wp_query not working with post_type
- Adding a tax_query to a WP_Query Object
- Woocommerce – exclude only older out-of-stock items
- Woocommerce pagination and result count after custom loop
- How to query woocommerce product by pricing? [closed]
- Finding WordPress Posts assigned to multiple categories
- Order or Orderby in tax_query (How to define order of terms in WP_Query)
- How to order WP_Query to group results?
- Redirect Search to Form When No Product Results Are Found
- How to add tax_query to $args with concatenation
- WP_Query Taxonomy categories filtering
- Exclude a Woocommerce product from WP_Query
- Woo Commerce using WP_Query to get products that match price range, with an additional required product attribute
- How to print term name inside wp post loop
- Get posts in taxonomy randomly
- Multiple meta_key ordering with pre_get_posts
- How to echo woocommerce category name
- Assign a minimum result count for WooCommerce query shortcodes?
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- Woocommerce: order posts by meta key
- Unlimited Page Sitemap Link
- Tax_Query using WP_Query not working
- $wp_query->found_posts not returning correct value
- Any quicker alternative for WP_Query “NOT IN”
- Woocommerce Shortcode which displays a table with product data
- Make a products only viewable to a specific user ID in meta_query pre_get_posts
- Customize the Sorting Dropdown in WooCommerce use another list or more page
- ElasticPress is (aparently) messing with my search filters
- How can I filter products by meta in Woocommerce REST API?
- wp_query with meta_query and tax_query
- What code to use in an array to call the current sub-category?
- Get categories within specific term
- How to display Woocommerce products list by tag
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- Woocomerce – Order products by float attribute in archive pages
- Not able to fetch woocommerce variation sales products for particular category products
- Slow Query with more 100 products
- Create global array to compare inside a query
- WordPress tax_query ignoring relation OR
- WP_Query to Retrieve Posts from WooCommerce Products that are Only in Catalog
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Woocommerce WP_Query post__not_in problem
- display all posts from category with and without terms in chronological order
- In Product Category archives how to show Posts having same/similar prod_cat slug structure?
- Using the same WP_Query for shop and widgets in WooCommerce shop
- How can I get all the posts that are related with a specific taxonomy term?
- How to combine nested tax_query logic with other nested query logic?
- tax_query not working for taxonomy slug
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- Custom query for tag and custom tag from 2 post type
- List posts of terms but exclude one term
- Output ACF field dynamicaly within a taxonomy loop [closed]
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- Custom query with custom filtering returning incorrect results
- WP_Query (or WC_Product_Query) out of memory