You can nest your tax queries. Just make sure you use OR
as the first relation and AND
relation on the nested tax queries.
$filter_group_a = array(
'relation' => 'AND',
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $term_a,
),
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $term_b,
),
);
$filter_group_b = array(
'relation' => 'AND',
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $term_a,
),
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $term_c,
),
)
$query_args = array(
'tax_query' => array(
'relation' => 'OR',
$filter_group_a,
$filter_group_b,
)
);
You could write some fancy loop that builds the $filter_groups
and pushes them to the $query_args['tax_query']
array.
Related Posts:
- How to query only for products with status “in stock” in WooCommerce? [closed]
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Hide products in uncategorized category from search results
- How to echo woocommerce category name
- What code to use in an array to call the current sub-category?
- Get categories within specific term
- Exclude or Include category ids in WP_Query
- WP_Query: Exclude hidden products from WooCommerce product list
- WP_Query to show post from a category OR custom field
- Query WooCommerce orders where meta data does not exist
- Display recent posts from the same category as current post in sidebar
- Changing a theme’s search function to only show results from woocommerce?
- Counting number of posts with Category B in Category A
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- Display featured products through custom loop in WooCommerce 3 [closed]
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- Get product list of given category
- How to exclude products by tag from woocommerce shop page?
- How To Remove/hide some specific categories from two different categories widget from sidebar
- WooCommerce Only OnSale Products Loop Snippet [closed]
- How to get the WC_Product Object when using a WP_Query in WooCommerce
- Extending woocommerce admin product search
- merge two query arguments into one WP_Query call
- List of the years with posts presented
- WC displaying products from category
- Show all post for a given category
- Sort by price woocommerce by ID post_meta
- How to get all product attributes for filters in WooCommerce?
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- Can we return all category (not post) with Custom Query Filter? [closed]
- Extend product search with meta in WooCommerce
- Query posts intersecting tags and categories
- Query posts from category A, and from either category B or C
- Woocommerce – Changing the order of the upsell products [closed]
- Exclude Category filter from Portfolio section
- Redirect to another page using contact form 7? [closed]
- Limiting number of related posts
- Category ‘pad_counts’ & ‘parent’ conflict
- Woocommerce – exclude only older out-of-stock items
- How to query woocommerce product by pricing? [closed]
- Include posts from some categories while excluding from others
- How to order WP_Query to group results?
- Woo Commerce using WP_Query to get products that match price range, with an additional required product attribute
- Assign a minimum result count for WooCommerce query shortcodes?
- Woocommerce: order posts by meta key
- Slider won’t work with custom query
- WP_Query with one category in args shows other categories
- How order posts from category by date and comment count?
- WP_Query for products always returns empty
- Related Posts Excluding Certain Categories
- Unlimited Page Sitemap Link
- $wp_query->found_posts not returning correct value
- Post incorrectly excluded when using “category__in”?
- Filter sub-category from checkbox form
- `offset` WP_Query argument dont work via `pre_get_posts`
- Use get_cat_ID to retreive multiple category IDs
- Function the_posts_pagination() not compatible with WP_Query arguments
- adding pagination to a foreach loop in wordpress
- Make a products only viewable to a specific user ID in meta_query pre_get_posts
- query hook parse_tax_query function takes no effect
- Woocommerce Get Orders By Meta Value
- Save large WP_Query to transient === false
- 3 posts from each existing category on one page
- Custom Woocommerce Product Query
- How to display the category dropdown auto search list when key press?
- Categories In English version showing not canonical URL, instead shows query search result
- How to show specify category template for both parent and child category
- Pagination for Category does not work
- How to display Woocommerce products list by tag
- Exclude parent categories from recent posts list
- Woocommerce featured products query no longer working
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- Check the product in the cart from which category is and show message
- WP_Query showing all posts, except from category X, unless it’s also in Y
- Woocomerce – Order products by float attribute in archive pages
- Single query for multiple categories
- Not able to fetch woocommerce variation sales products for particular category products
- Multiple values in WP_Query : category__and
- How to exclude posts by ID within a category/archive loop
- I have 3 categories, i want to display on a loop the last 3 of every category
- Get posts with any value in attribute
- Adding Category in WP_Query Not Working
- WP_Query to Retrieve Posts from WooCommerce Products that are Only in Catalog
- Making Woocommerce optimized for more than 500k products
- Woocommerce WP_Query post__not_in problem
- display all posts from category with and without terms in chronological order
- Pull posts from all categories if quantity is not met?
- Category Archive not working for pages
- Using the same WP_Query for shop and widgets in WooCommerce shop
- Retrieving category pages from subcategory returns empty sets
- Display Count of posts
- query_posts problem – need help
- Adding arguments to WooCommerce Product Loop using AJAX
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Filtering product search results using tags
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- I need to get all categories from a WP_Query
- How to get post taxonomy url and name in wp_query
- WP_Query (or WC_Product_Query) out of memory
- Excluding a category from frontpage but not from WP_Query