Woocommerce Product title with custom product attributes

Hi guys. I created custom woocommerce product attribute “artist” and I need to add that in the title of single product.

like “artist” - “woocommerce_product_title”

for example
product - Greatest Hits
Artist - Queen

product title in a single product page “Queen - Greatest Hits”

How can I do that in layout editor?
thx

Hi @uncleshneerson,

Thanks for reaching out.
To add the Artist with the Product title, you need to modify the following WooCommerce hooks. Please add the following code into functions.php of the child theme.

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
function woocommerce_template_single_title_custom()
{
    $additional_text = ' More Info ';
    the_title( '<h3 class="product_title entry-title">'.$additional_text,' </h3>' );
}
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title_custom', 5);

Please remember that the above code will work if copied as it is and don’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle.
We really do not provide support for custom codes that means we can’t fix it in case it conflicts with something in your site nor will we enhance it.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.