Skip to content

Instantly share code, notes, and snippets.

@growdev
Last active April 6, 2017 15:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save growdev/4074021 to your computer and use it in GitHub Desktop.
Save growdev/4074021 to your computer and use it in GitHub Desktop.
WooCommerce - Remove the "Related Products" section from a template by removing the related posts query arguments.
<?php
/*
* wc_remove_related_products
*
* Clear the query arguments for related products so none show.
* Add this code to your theme functions.php file.
*/
function wc_remove_related_products( $args ) {
return array();
}
add_filter('woocommerce_related_products_args','wc_remove_related_products', 10);
@noelmcg
Copy link

noelmcg commented Apr 5, 2017

This doesn't seem to work with Woocommerce 3.0

@lucspe
Copy link

lucspe commented Apr 6, 2017

In WooCommerce 3.0 this will not work.

Working code (assuming that you use the default WooCommerce template):

add_action( 'init', 'woocommerce_remove_related_products' );
function woocommerce_remove_related_products() {
	remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment