how to add a custom text to product title?

Pending
REHub - Price Comparison, Affiliate Marketing, Multi Vendor Store, Community Theme REHub - Price Comparison, Affiliate Marketing, Multi Vendor Store, Community Theme August 08, 2022
Login to reply
Igor Sunz Support Agent
2 years ago

sorry, but your support is expired so we can't provide any customization help

Tim Kerremans
2 years ago

 am trying to add product category to the product title using this code on functions.php on child theme but its not working the way i want, please check the attached image:

remove_action( ‘woocommerce_single_product_summary’,’woocommerce_template_single_title’, 5 );

add_action( ‘woocommerce_single_product_summary’, ‘custom_product_category_title’, 6 );

function custom_product_category_title(){

global $post;

$terms = get_the_terms( $post->ID, ‘product_cat’ );

$title = ”;

foreach ($terms as $term) {

$title = $term->name .’ ‘;

}

echo “<h1 class=’product_title entry-title’>”.$title.”</h1>”;

}

any advice would be great!

Additional Info

Link on page with issue: https://www.staging5.holymowly.com/shop/a-gate-of-new-hope-canvas/