Add this to your functions.php
function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( 'tax_query' ); $tax_query[] = array( 'taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => array( 'banana' ), // Don't display products with the tag "banana" 'operator' => 'NOT IN' ); $q->set( 'tax_query', $tax_query ); } add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );
Related Posts:
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Posts with at least 3 tags of a list of tags
- WP_Query: Exclude hidden products from WooCommerce product list
- Query WooCommerce orders where meta data does not exist
- Better way to get tag stats?
- Given a WP_Query, how can I get a list of tags?
- Executing Queries in tag.php
- post_type is ignored by WP_Query when ‘tag’ argument is included
- Changing a theme’s search function to only show results from woocommerce?
- Get WooCommerce best selling products for the current month [closed]
- Woocommerce query by price range and custom meta key
- Order posts by tags count?
- Retrieve products with specific attribute and in category – woocommerce
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Find all product that contain terms with %keywords% in WP_Query
- Display featured products through custom loop in WooCommerce 3 [closed]
- WP Query – Get WooCommerce Products with variation that is in stock
- Search product by brand name in wp_query
- Get product list of given category
- Pagination problem after WP_Query with tag filtering
- 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
- reducing the amount of wp_query calls
- Woocommerce returns Product post_status as published even tho it is in status draft
- WordPress Related Post by tags in Single.php
- WC displaying products from category
- How to build a WP_Query using mulitple tags and using AND or OR operator between them
- Include tags in WP_Query
- Search for multiple tags?
- Display posts from only one post form in custom query and exclude in main query
- Take all produts by category
- Sort by price woocommerce by ID post_meta
- How to get all product attributes for filters in WooCommerce?
- Extend product search with meta in WooCommerce
- Display tags with random thumbnail from selection of posts with that tag
- WooCommerce – get product sub categories
- Query posts intersecting tags and categories
- Woocommerce – Changing the order of the upsell products [closed]
- Combining categories (Query posts with multiple taxonomy terms)
- How to not display tags with less than X posts
- Woocommerce – exclude only older out-of-stock items
- Need Sub-category with main Category
- How to query woocommerce product by pricing? [closed]
- How to order WP_Query to group results?
- Can’t fetch Custom Post Type Data through Custom Query
- Redirect Search to Form When No Product Results Are Found
- exclude product with available tag
- How do I get Woocommerce product variation name and variation description in a WP_Query?
- Hide products in uncategorized category from search results
- Woo Commerce using WP_Query to get products that match price range, with an additional required product attribute
- How to echo woocommerce category name
- Woocommerce: order posts by meta key
- WP_Query by keyword OR post tag
- WP_Query for products always returns empty
- Display posts by tag
- Creating attachments archive in tags and categories
- Unlimited Page Sitemap Link
- Filter products on category AND tag
- Make a products only viewable to a specific user ID in meta_query pre_get_posts
- ElasticPress is (aparently) messing with my search filters
- Woocommerce Get Orders By Meta Value
- Save large WP_Query to transient === false
- Custom Woocommerce Product Query
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- How sort products by calculate value? ( custom post meta, price, option)
- wc_get_products() return empty object
- Get posts that match defined arrays of tags
- WooCommerce. How To Exclude Subcategory Products From Category Listing Page
- get_posts return only first result
- What code to use in an array to call the current sub-category?
- Get categories within specific term
- Order posts by tags count?
- How to display Woocommerce products list by tag
- Fix wp_term_relationships slow query in get_posts
- Woocommerce featured products query no longer working
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- update_post_meta performance in a loop woocommerce
- update_post_meta performance in a loop woocommerce
- getting posts by tags
- Query child posts with tax query on parents
- Search with WP_Query, but ignore href URLs in anchor tags?
- Not able to fetch woocommerce variation sales products for particular category products
- Show posts from categories instead of tags
- Get posts with any value in attribute
- How do i query woocommerce booking post type on init action?
- WP_Query to Retrieve Posts from WooCommerce Products that are Only in Catalog
- post_type not working when tag__in is present?
- Exclude all tagged posts from WP_Query loop
- How to create page that lists tags by initial letter?
- Using the same WP_Query for shop and widgets in WooCommerce shop
- Woocommerce orderby rand with tax_query not random
- Random posts in WP_Query when searching by tag
- Limit Tags display and ad Drop Down Menu
- Adding arguments to WooCommerce Product Loop using AJAX
- Show linked products using wp query and woocommerce
- Filtering product search results using tags
- Variations as Single Products [closed]
- WP_Query (or WC_Product_Query) out of memory