I have a child theme that I am trying to override a WooCommerce function.
WooCommerce file in plugin location: woocommerce/includes/wc-template-hooks.php
. I created a new file in the same hierarchy in my child theme and it’s located here: my-child-theme/woocommerce/includes/wc-template-hooks.php
My edited section is I commented out the product title in child theme:
/**
* Product Summary Box.
*
* @see woocommerce_template_single_title()
* @see woocommerce_template_single_rating()
* @see woocommerce_template_single_price()
* @see woocommerce_template_single_excerpt()
* @see woocommerce_template_single_meta()
* @see woocommerce_template_single_sharing()
*/
//add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); //commented
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
However, when I goto my product page, I still see the title.
Any idea what I am doing wrong?
2
Answers
You need to remove action
woocommerce_single_product_summary
to this work properly.Just add this to your
functions.php
and will do the magic.You also can try to add
remove_action()
out of theadd_action()
. Just like this……directly to
functions.php
Play with it.
TIPS & TRICKS
If you want to change your HTML in the title or do anything you want, here is example:
One important thing:
If you change the template folder within the Woocommerce plugin, there is a good chance that you will lose your settings after the plugin update. That is why it is better to work in an active theme.