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.
1 2 3 4 | /** * Remove related products output */ remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); |
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”.
1 2 3 4 5 6 7 8 9 10 11 12 | /** * Hide related products from certain categories */ function winwar_hide_category() { if ( is_singular( 'product' ) ) { if ( has_term('tshirts', 'product_cat' ) ) { remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); } } } add_action( 'wp', 'winwar_hide_category', 10 ); |
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:-
1 2 3 4 5 6 7 8 9 10 11 12 | /** * Hide related products from multiple categories */ function winwar_hide_category() { if ( is_singular( 'product' ) ) { if ( has_term('tshirts', 'product_cat' ) || has_term('hoodies', 'product_cat' ) ) { remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); } } } add_action( 'wp', 'winwar_hide_category', 10 ); |
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:-
1 2 3 4 5 6 7 8 9 10 11 12 | /** * Hide related products from certain products */ function winwar_hide_product() { if ( is_singular( 'product' ) ) { if ( is_single( 47 ) ) { remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); } } } add_action( 'wp', 'winwar_hide_product', 10 ); |
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:-
1 2 3 4 5 6 7 8 9 10 11 12 | /** * Hide related products from certain products */ function winwar_hide_product() { if ( is_singular( 'product' ) ) { if ( is_single( array( 45, 47 ) ) ) { remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); } } } add_action( 'wp', 'winwar_hide_product', 10 ); |
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.






