Reputation: 409
There is a WooCommerce hook in single product page template, which execute 7 functions that displays title, rating, price, buttons, descriptions, etc…:
<?php
/**
* woocommerce_single_product_summary hook.
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
*/
do_action( 'woocommerce_single_product_summary' );
?>
How can I use woocommerce_template_single_title
to display product title at the top of my page?
Then I would like to use woocommerce_template_single_title
to display this title in the sidebar woocommerce template and for example in the middle of the page.
I am customizing my WooCommerce theme and I need to change some WooCommerce hooks behaviors.
Is there a WordPress function that filters or limits a WooCommerce hooks behaviors?
Thank you
Upvotes: 0
Views: 1891
Reputation: 254388
For your Product title in single product page, you can first remove it with remove_action this way:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
Then you can added it again at the top of your page with:
add_action( 'woocommerce_before_single_product', 'woocommerce_template_single_title', 5);
Or
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 5);
You have to test which one is better for you.
So know you know how to remove hooked function with remove_action() and hook it again anywhere in WooCommerce templates with add_action().
When you use remove_action for an hooked function, you will need to use same priority.
Inwoocommerce_single_product_summary
hookwoocommerce_template_single_add_to_cart
function is hooked with a priority of 30, so when usingremove_action()
you will need to use same priority.Priority: Higher is the priority, lower is the number (for add_action()).
Upvotes: 1