Related Products by Tag Only
Makes the related products section match products by shared tags instead of shared categories, for more precise suggestions.
Opens WPIDE on
Code
add_filter( 'woocommerce_product_related_posts_relate_by_category', '__return_false' );
add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_true' );
Notes
Products without tags will show no related products.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.