Welcome Guest! Login? Checkout

By default, WooCommerce often shows related products beneath each product on a single page, you can see it using my child theme of choice: Understrap.

This is the default option within WooCommerce, and there’s no easy way to turn off this unfortunately. It does seem to be present on all sites. It’s probably with good reason: related products have time and again shown that they increase sales, and most shops will want them on.

However, depending on your setup on your site, you may wish to switch them off. This blog post will show you how.

WooCommerce – Remove All Related Products

The following code will remove all related products. This needs to be added to a plugin or your theme’s functions.php file (probably better adding it to your theme). This will disable the related products box throughout the site.

WooCommerce – Hide Related Products from Certain Categories

You may wish to hide related posts from certain categories. Thankfully this too is a simple three lines of code. Say for example you wish to remove this from a category called “tshirts”.

Should you wish to hide from multiple categories, then you can expand line 7 to search multiple categories. So for example, if you wish to hide the related products from tshirts and hoodies, do the following:-

WooCommerce – Hide Related Products from Certain Products

Similarly, you may want to hide related posts from certain products. Similarly to the previous example, you can apply a filter after the page loads but before the related products section is displayed. You will need to grab the ID of the product, so say if you want to hide the related products on a product with the ID of 47, do the following:-

The is_single command does accept an array, so you can add multiple IDs, so if you want to hide related products on products with ID of 45 or 47, do the following:-

And there you have it! If you have WooCommerce, how to remove related products should now be straightforward. You can expand this to create an interface that can make this user friendly, but that would probably suit a plugin better.

If you have any questions, please drop them in the comments. You can also read more WooCommerce Tutorials on our site.

 
 
 
WP Engine Managed WordPress Hosting

Comments

Polite Disclaimer: I am welcome, open and willing for corrections to be shared in the comments (with corrections being added to posts and credited), and the comments field should be used to promote discussion and make this post better. I do not know everything and if anybody finds a better way to do something, then by all means please share it below.

However, I'm unable to offer support to posts. The reason being is that WordPress has tens of thousands of plugins and millions of themes. As such, finding out exactly why code doesn't work with your setup is a long process. If you wish for me to look at your code, please use the priority support area.

Comments asking support will be left on the site, but there is no guarantee of answer.

    Leave a Reply

    Your email address will not be published.

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">
    *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.