//this is how i added AND filter on product tags
function product_tag_and_filter( $query ) {
if ( is_admin() || ! $query->is_main_query() ){
return;
}
if(is_product_category()){
$tax_query = array();
// add meta_query elements
if( !empty( get_query_var( 'product_tag' ) ) ){
foreach(get_query_var( 'product_tag' ) as $val){
$tax_query[] = array( 'taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => $val , 'compare' => '=' );
}
}
if( count( $tax_query ) > 1 ){
$tax_query['relation'] = 'AND';
}
if( count( $tax_query ) > 0 ){
$query->set( 'tax_query', $tax_query );
}
}
}
add_action( 'pre_get_posts', 'product_tag_and_filter', 1 );
Related Posts:
- WooCommerce get physical store address
- How to hook on a WooCommerce checkout field?
- Woocommerce – How to add 5 stars to all products to test design
- How can I override these WooCommerce widget cart button functions
- How to get woocomerce attributes thumbnail in PHP? [closed]
- Programmatically added variations not showing until clicking Update button
- How to have specific prices for some particular pin codes in woocommerce? [closed]
- How to automatically add and show all the product attributes when creating a new product
- Import products to WooCommerce by CSV page won’t open [closed]
- How can i change the design of product sizes [closed]
- How do I get the latest note on the order at woocommerce? [closed]
- Woocommerce Login Redirect not working [closed]
- Output JSON object with woocommerce products
- Register a new user on wooCommerce using Rest API
- Woocommerce REST API allow normal users make an order
- WooComerce shows blank site (Shop)
- How to update custom field in WooCommerce
- Add product categories to receipt
- Woocommerce specific product template for product type
- How can I use a gravity form to send an e-card?
- How to select default Woocommerce category page
- Timber, Twig, and Woocommerce: Last product stays in the cart after checkout
- Woocommerce Cart Default Language Not Changing
- Make this Fast and Queryable
- WooCommerce slider filter for numerical attributes
- *Woocommerce* Past Orders Disappeared after changing Stripe Account [closed]
- Need help in handling woocommerce api timeout issue [closed]
- create custom layout product list woocommerce [closed]
- Reordering product tab under product image [closed]
- How do I change the default state label for a country on the WooCommerce checkout page?
- WooCommerce Tax Filter Not Fired [closed]
- woocommerce – customise notice error in checkout page
- Using a filter to change a path
- Woocommerce, prevent login after registration and redirect to custom URL
- Order with custom order status disappeared once the page is refreshed
- WooCommerce Product detail page: Add content under thumbnails [closed]
- How to add product filter dropdown in woo commerce order page?
- Hide price and add to cart button on product page only
- How to make a custom button that redirects to a “user specified link while entering product details” woocommerce
- Unable to paste google analytics con header.php [closed]
- wordpress/woocommerce login url not redirecting correctly
- Add Attribute to Woocommerce programatically, doesn’t display front end [closed]
- How do I make the product image smaller on a WooCommerce product page?
- How do i make this snippet work for order history page woocomerce
- Set QTY to 0 With WP All Import from CSV
- Link a button to woofunnels model
- Woocommerce – Add additional item if some item wants to be added to the cart?
- Hook “wp_trash_post” executing multiple time in case of bulk trash products
- WooCommerce Subscriptions: Hide one variation subscription
- Contact form 7 send product PDF after submit
- Add sub variations in product page
- Woo commerce product quantity wise SKU
- validation field form registration vendor dokan woocommerce
- Delete unpublished woocommerce products
- List of JS events in the WooCommerce frontend
- Woocommerce / Product Columns on Shop Loop / Responsive
- I’m getting error Ultimate WooCommerce Filters
- No Results in WooCommerce Product Search
- WooCommerce Product Search box with 3 dropdown menus
- Split taxonomies on different pages
- woocommerce REST api on the website’s front-end
- Can’t add Select2 to select in variable product (admin)
- How to do_action after some plugin{woocs} loaded?
- How can I change field values of posts before displaying
- Url parameter going to 404 not found
- Working with a json feed & trying to figure out how best to import
- Editing fields required in the WooCommerce / WordPress registration form [closed]
- WC Booking query bookings with date ranges
- The orders in WooCommerce admin are hidden (they have the “hidden” CSS class)
- Disable theme WooCommerce template [closed]
- WooCommerce: how to set stock per attribute on variable product
- How to display products in sidebar in 2 columns?
- How to hook in to WooCommerce Related Products
- Increase load-out-page speed
- WooCommerce Stucked (?) – Edit dimensions
- woocommerce – undelete posts
- How to add a fixed shopping cart button on the bottom of the page?
- WooCommerce and Theme templates
- WooCommerce Hook after Billing form completed, but before payment Gateway
- PHP Warning: Error while sending QUERY packet
- Add category description on product page (Woocommerce)
- Hide .woocommerce-price-suffix on the product list page
- Woocommerce cart displays outdated prices [closed]
- How to Manage Multiple WordPress Websites from one dashboard (WooCommerce)
- Setting stock levels to “0” for all products in store using WP CLI
- Custom e-commerce display for specific users [closed]
- How to get the attributes based on dependency in woocommerce?
- Woocommerce composite and bundle products
- WooCommerce Review ID Block
- custom status in Woocommerce with database results
- Question about WooCommerce Subscription
- WooCommerce: Redirect to an item’s product page after item is removed from cart
- Blurry product card image – rendered is 486×452 vs 300×279 in real image. Smaller versions being autocreated and served using srcset
- how to show itemized shipping cost|? [closed]
- GET woocommerce order request is not showing meta data [closed]
- Add a custom meta column to a built-in import CSV file
- Hide/show button for the password field in the Woocommerce My Account page
- I need help with CPT for a food delivery business
- Woocommerce admin order email customize – remove product short description
- Which php files, in a WordPress setup, do not need direct web access?