Snippet

Hide ‘Related Products’ Section on WooCommerce Product Page

How to hide related products in woocommerceRemove related products woocommerceDisable related products on woocommerce product pageHide related products section woocommerceWoocommerce remove related products without codeTurn off related products in woocommerceWoocommerce hide related products with pluginRemove related products from woocommerce product pageHow to disable related products in woocommerceWoocommerce related products removal guide

Explanation

If you're looking to hide the 'Related Products' section on your WooCommerce product pages, there's a simple way to do it without diving deep into complex coding.

Here's what you need to know:

  • This solution involves adding a small piece of code to your theme's functions.php file.
  • The code works by using a filter to change the arguments that WooCommerce uses to display related products.
  • By returning an empty array, it effectively tells WooCommerce not to show any related products.

Remember: Always back up your site before making changes to your theme files. This ensures you can easily revert back if something doesn't work as expected.

With this tweak, your product pages will no longer display the related products section, giving you a cleaner look or more control over what your customers see.

Code

1<?php 2// Function to remove related products from WooCommerce product pages 3function wp_dudecom_remove_related_products( $args ) { 4 return array(); 5} 6 7// Hook the function to the WooCommerce related products filter 8add_filter( 'woocommerce_related_products_args', 'wp_dudecom_remove_related_products', 10, 1 ); 9?>

Instructions

File Location: functions.php

Prerequisites:

  • Ensure WooCommerce is installed and activated on your WordPress site.
  • Have access to your WordPress theme's files, specifically the functions.php file.

Implementation Steps:

  1. Backup Your Site: Before making any changes, ensure you have a complete backup of your WordPress site. This is crucial to avoid any data loss.
  2. Access Theme Files: Log in to your WordPress admin dashboard.
  3. Navigate to Theme Editor: Go to Appearance > Theme Editor. If prompted, select the active theme you are using.
  4. Open functions.php: In the right-hand sidebar, find and click on Theme Functions (functions.php).
  5. Add the Code: Scroll to the bottom of the functions.php file and paste the provided code snippet.
  6. Save Changes: Click the Update File button to save your changes.
  7. Verify: Visit a product page on your site to ensure the 'Related Products' section is no longer displayed.

If you encounter any issues or need further assistance, consider reaching out to wp-dude.com for professional help with WordPress implementations and advanced functionality.