Disable Related Products in WooCommerce Product Pages
There are many reasons to not include related products on your store. Regardless of those reasons, there’s a couple options for you if you’re looking to remove, or stop, the related products from showing on your store.
How do I stop related products from showing in the store?
Option 1: Using your theme
If you are using a pre-built theme, chances are that they have an option for to control this section. It's likely something you may find under the single product page options. If you're theme has this customization option built in then you can remove the related products without using any code.
So be sure to check your theme settings or options to see if this is something you can just enable or disable there! If you're unsure where to look check for your themes options page, if it provides one, or the WordPress theme cutomizer.
Option 2: Using some code
If you are using a custom built theme, or a theme that doesn’t have an option to remove the related products from the single product page - you're not out of luck. You can add the following code snippet to your theme’s functions.php file. Take note, we provide two methods to accomplish this task - you should try the top method first and attempt the alternative method if that one does not work.
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
add_filter('woocommerce_product_related_posts_query', '__return_empty_array', 100);
This single line of code should be enough to disable the related products from showing up. In fact, this line actually simply removes the related products 'action' from being run on the page all together. If for some reason this does not work for you and the theme you're using you can try the second (alternative) method provided!
About the Author: Dan Pock
Dan Pock does technical support at Liquid Web with a background in System Administration, Public Relations, and Customer Service. His favorite things include his cats, Oscar Boots, and Dash Nougat; experimenting with PHP; and making up recipes (or at least attempting to). You can find his coding hijinks on GitHub, where he shares most of his projects and open source work.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Guide on Connecting to Remote Servers Using SSH in Linux, Windows, or macOS SystemsRead Article
New User Tutorial: What is DNS?Read Article