WooCommerce PHP Beginner Requires WooCommerce

Remove Related Products From Product Pages

Remove the "Related products" section from single product pages.

Tested on WordPress 7.1 PHP 8.3 Updated
functions.php 3 lines
add_action( 'init', function (): void {
	remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

Related products are picked automatically by category and tag, and on small stores they can be a random mix. If they don’t help sales, this snippet removes them.

How it works

WooCommerce adds the section to woocommerce_after_single_product_summary at priority 20. The snippet removes that action on init, after WooCommerce has set up its template hooks. Upsells, which you choose by hand on each product, are not affected.

Things to watch

  • Some themes move related products to a different hook or priority. If they still appear, check your theme’s functions.php for where it adds them.
  • Block themes show related products with the Related Products block in the Single Product template. Remove the block there.

How to test it

Open any product page. The “Related products” heading and grid should be gone.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only