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
- How to query only for products with status “in stock” in WooCommerce? [closed]
- Query WooCommerce orders where meta data does not exist
- Better way to get tag stats?
- WP_Query for WooCommerce Products
- Given a WP_Query, how can I get a list of tags?
- Executing Queries in tag.php
- How to order posts tag by tag?
- post_type is ignored by WP_Query when ‘tag’ argument is included
- WP Rest API v2 return posts with specific tag
- Changing a theme’s search function to only show results from woocommerce?
- Get WooCommerce best selling products for the current month [closed]
- Loop through all tags & output posts in alphabetical list
- Woocommerce query by price range and custom meta key
- Order posts by tags count?
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- Retrieve products with specific attribute and in category – woocommerce
- How to combine tax_query and date_query in WordPress
- How to get any tag ID
- how to retrieve specific product attribute value in an sql query?
- Get all posts without tags
- 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
- Query post from all category with same tag on 1 pages
- 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
- showing all search result in one template
- Get all products which have both product 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
- Woocommerce query all products and categories
- Take all produts by category
- Sort by price woocommerce by ID post_meta
- How can I make WP_Query get posts that have a tag but also have random other tags?
- How to get all product attributes for filters in WooCommerce?
- WP_QUERY to display woocommerce products whose author IS the logged in user
- 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
- Having trouble with WooCommerce Storefront child theme single.php “related posts” modification [closed]
- Woocommerce – Changing the order of the upsell products [closed]
- Out Of memory issue on post per page parameter
- Combining categories (Query posts with multiple taxonomy terms)
- wp_query not working with post_type
- Order by most used tag
- WP Query with multiple tags by get the tags
- How to not display tags with less than X posts
- Woocommerce – exclude only older out-of-stock items
- Need Sub-category with main Category
- Woocommerce pagination and result count after custom loop
- How to query woocommerce product by pricing? [closed]
- How to order WP_Query to group results?
- Query Posts by Tag and exclude
- Can’t fetch Custom Post Type Data through Custom Query
- Get posts that do not have the same tags as current
- 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?
- WP_Query Taxonomy categories filtering
- Exclude a Woocommerce product from 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
- Multiple meta_key ordering with pre_get_posts
- How to echo woocommerce category name
- Assign a minimum result count for WooCommerce query shortcodes?
- Woocommerce: order posts by meta key
- WP_Query by keyword OR post tag
- var_dump of WP_Query object is not empty, while .have_posts() return false
- WP_Query for products always returns empty
- Display posts by tag
- Creating attachments archive in tags and categories
- Get posts with no tags?
- Unlimited Page Sitemap Link
- $wp_query->found_posts not returning correct value
- Tax Query on product_cat using NOT IN as operator does not exclude that category
- Woocommerce Shortcode which displays a table with product data
- Filter products on category AND tag
- 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
- Only show tag with the same id as the post
- 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