The code snippet below will allow you to remove related products from your WooCommerce store, in case you had everything in your store setup just right, and you didn’t want to feature cross sells in your site.
Cross sells and upsells
Its worth first understanding which related products are being displayed in your site (the code for which we won’t go into here) – so when testing, you should try adding a “cross sell” and an “up sell” to a product in your site, and seeing where these are displayed by your theme.
Where these are placed in your WooCommerce theme are really down to which theme you are using, though the description below will work on themes like WordPress Twenty Seventeen (i.e. the default wp theme!), or the WooCommerce Storefront theme to remove your site’s related products section.
Remove Related Products from WooCommerce
Add the below code to your theme’s functions.php file. This is best done in a child theme so your updates don’t get overwritten if you upgrade your theme.
This will remove them – not just hide them – from being called at all. Be aware that using a CSS hack like
display:none; still calls the PHP and therefore adds load to your store, to pull in products you are hiding. This is slow and therefore sub-optimal. Use the code below to prevent the query from happening and keep the speed going too!
Leave a comment below if this worked / didn’t work for you!
Get help and support with your WooCommerce store
If the above didn’t work for you, or you have other questions, and would to have accredited WooCommerce developers to check over your Woo store, please contact us. If you’re in Australia, our Australian WooCommerce support team can help.