Here's a part of codes in wc-template-hooks.php
:
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
Here's the code from content-single-product.php
do_action( 'woocommerce_after_single_product_summary' );
What code should I put in content-single-product.php
to remove woocommerce_output_related_products
without editing the wc-template-hooks.php
.
Sorry, I'm new in PHP. Thanks in advance.
You dont have to put it in content-single-product.php, try adding it to functions.php and if you just need to remove it on a single products page use woocommerce conditional functions to allow it only on the pages you want. for instance.
<?php if(is_product()){
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); }?>
I have tried all above solutions but not working. Woo-commerce Version 3.4.1
Working Code, Added in child theme in functions.php
add_filter('woocommerce_product_related_posts_query', '__return_empty_array', 20);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With