I would like to edit the template of my Single product page.
I tried to use the WC hook woocommerce_single_product_summary
in my child's functions.php
to add custom field right below the title, but unfortunately the hooks behave strange, as described below.
I tried to add this line of code:
add_action('woocommerce_single_product_summary', 'display_speaker_name', 6);
function display_speaker_name() {
echo '<p>' . get_field('speaker_name') . '</p>';
}
But what it does is, that it displays the custom field on the top of the summary section above the title. When i try to change the priority to 11, it displays at the bottom of the section, below the categories. I looked into the WC documentation and the priority of woocommerce_template_single_title
hook should be 5. So if I understand that correctly, the proper priority for my custom hook should be between 6-9, if I want to display it below the title, right?
I even looked to the wc_template_hooks.php
and the priority of the default WC hooks is set properly there. Also I tried to remove the original WC title hook and then add it with the priority 5, but unfortunately it did not work as well.
Do you have any ideas, how to solve this problem? I am using OceanWP theme. Thank you!
EDIT: See comments on the first answer for the solution.