How to Remove Related Products in Woocommerce
For numerous WooCommerce store owners, ensuring a tidy and focused product page is crucial. They strive to deliver a seamless shopping experience. A frequently customized element is the display of related products, visible by default on the single product page. In this concise tutorial, we’ll walk you through a straightforward PHP solution. This will help you remove related products, maintaining clutter-free and user-centric product pages.
PHP snippet to remove related products
// Remove Related Products from WooCommerce Single Product Page
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
This line of code removes the action hook
woocommerce_output_related_products from the
woocommerce_after_single_product_summary hook with a priority of
20. In essence, it interrupts the default behavior that appends related products to the product page.
Follow these simple steps to implement the PHP snippet:
- Access Your Theme Files: Utilize a file manager or an FTP client to access your WordPress theme files.
- Edit functions.php: Locate and edit the
functions.phpfile within your active theme directory.
- Insert the PHP Snippet: Copy the PHP snippet and paste it at the end of the
- Save Changes: Save the modified
By using this simple PHP solution, you can quickly remove related products from your WooCommerce single product pages. As always, before making any changes to your site, consider creating a backup and test the modifications on a staging environment to ensure compatibility with your specific setup.