I try to get the opposite of: Related Products only by categories, not by tags in WooCommerce 3
I would like to show related products based only on product Tags, and Not by categories.
So far I have this in my function.php
under my child theme:
add_filter( 'woocommerce_get_related_product_cat_terms', function( $term_ids, $product_id ){
return array();
}, 10, 2 );
But it doesn't work.
Any help is greatly appreciated.
In woocommerce version 3.2.x, I have tested first this code to only show related products based on product tags only:
add_filter( 'woocommerce_product_related_posts_relate_by_category', '__return_false' );
For product tags you will use:
add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' );
Code goes in functions.php file of your active child theme (or active theme). It works perfectly.
Important: To see changes, clear transients by going in WooCommerce > Status > tools and in "WooCommerce transients" click on "Clear transients" button.
Your code works too, so there is something that is making trouble. It can be a plugin, your theme or some other code made by you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.