Remove Categories and only use Tags to show Related Products in WooCommerce

Related products being retailed together

Below is a snippet of code, and a simple video explanation, which shows you how to edit the output of WooCommerce related products (shown at the bottom of the single product page) in order to not use product category and only use product tags as a mechanism for measuring “relatedness”.

The Code Snippet

// Remove categories and only use tags in WooCommerce related products - By Robin Scott of Silicon Dales see
add_filter( 'woocommerce_product_related_posts_relate_by_category', '__return_false' );
view raw gistfile1.txt hosted with ❤ by GitHub

Where to put this code

Add this code into a child theme functions.php file, or a custom plugin, or (as in the video) a snippets plugin which holds only this piece of code.

The video guide

My video below explains how to use this code, what it does, and where to place it into your WooCommerce store.

In this video, you can see I’ve connected together relevant toy products using the product tag “Cap Guns” – but this rule can apply nicely to most stores, to build more relevant “related” products. In case you’d like to check the output in real time, this is the product in the video.

Get Things like this for your Woo store

Book Silicon Dales – contact us here – and we can carry out work like this on your WooCommerce store to make it stand out from the crowd, become more useful, and, ultimately, make more sales (we don’t guarantee this last part, but our work sure can help!).

1 thought on “Remove Categories and only use Tags to show Related Products in WooCommerce

  1. Code is updated, as the previous version wasn’t working. Tested and works as of 28 Oct 2019.

Leave a Reply

Your email address will not be published. Required fields are marked *