Change Product Tab Titles and Headings

Why do you think I decided to create a separate tutorial about renaming product tabs? 🤔 Because everything is not as simple as it seems, especially when we are talking about the Reviews tab.

Change Product Tab Titles

Let’s begin with the simple thing, luckily you can rename any of product tab titles, just by changing the title element of the $tabs array, example:

add_filter( 'woocommerce_product_tabs', 'misha_rename_additional_info_tab' );
 
function misha_rename_additional_info_tab( $tabs ) {
 
	$tabs['additional_information']['title'] = 'Product size';
 
	return $tabs;
 
}

All the code from this tutorial you can insert to your functions.php file, but please keep in mind that unless you are using your custom theme, it is better to insert the code into a child theme’s file or to a custom plugin.

And the result:

how to rename WooCommerce product tabs

By the way, if you do not need some of the default WooCommerce product tabs, you can check my another tutorial about removing them.

Rename Reviews Tab

But it doesn’t work out the same way for the “Reviews” tab. Why? Because this tab title displays the number of customer reviews as well!

Okay, there are two different approaches for this, in the first one we can just str_replace() the text “Reviews” and do not touch the count.

add_filter( 'woocommerce_product_tabs', 'misha_rename_reviews_tab' );
 
function misha_rename_reviews_tab( $tabs ) {
 
	$tabs['reviews']['title'] = str_replace( 'Reviews', 'What customers are saying', $tabs['reviews']['title'] );
 
	return $tabs;
 
}

In the second approach we can get the reviews count from the global $product object:

add_filter( 'woocommerce_product_tabs', 'misha_rename_reviews_tab' );
 
function misha_rename_reviews_tab( $tabs ) {
 
	global $product;
 
	$tabs['reviews']['title'] = 'What customers are saying (' . $product->get_review_count() . ') ';
 
	return $tabs;
 
}

No matter what way you will choose, it should work great:

How to rename WooCommerce product tabs

Change Product Tab Headings

Ok, we’ve figured it out how to rename tabs, but it is not a complete solution without changing the tab headings as well 🤔

Each tab has a different filter hook which allows to change its heading, let’s make a look at them separately.

Change “Description” tab heading

add_filter( 'woocommerce_product_description_heading', 'misha_description_heading' );
function misha_description_heading( $heading ){
 
	return 'My new heading';
 
}

Change “Additional information” tab heading

Everything is very similar to Description tab. Actually we have just the same code but with the different filter hook.

add_filter( 'woocommerce_product_additional_information_heading', 'misha_additional_info_heading' );
function misha_additional_info_heading( $heading ){
 
	return 'My new heading';
 
}

Change “Reviews” heading

Here is where the interesting things come in. Yes, we have a filter hook here… it is woocommerce_reviews_title but.. it only works in case you have reviews! So, if a product has no customer reviews, the hook won’t work!

Of course I will show you a solution, but let’s make a look on an example in case there are reviews:

add_filter( 'woocommerce_reviews_title', 'misha_reviews_heading', 10, 3 );
function misha_reviews_heading( $heading, $count, $product ){
 
	return 'What customers think about this product';
 
}

As you can see, it is not necessary to get the reviews count from global $product as we did it before, everything is already provided within filter hook arguments, you can even access a WC_Product object inside it.

And now shocking news – WooCommerce doesn’t have a hook for “Reviews” tab heading when there are no reviews! 😱

But I promised you a solution, right? 🔥👇

add_filter( 'gettext', 'misha_no_reviews_heading', 20, 3 );
function misha_no_reviews_heading( $translated, $text, $domain ) {
 
	if( is_product() && $translated == 'Reviews' && $domain == 'woocommerce' ) {
		$translated = 'Ooops... No reviews yet. Please leave one!';
	}
 
	return $translated;
 
}

Is it a clean solution to hook the translation? Kind of clean, if you’re absolutely sure that you have to rename this, you can use it, but please do not forget about all the conditional statements to prevent it from translating somewhere else you do not need.

In case you do not believe me, here is a screenshot 😁

Custom heading for Reviews product tab when there are no reviews

More about Product Tabs

Misha Rudrastyh

Misha Rudrastyh

I love WordPress, WooCommerce and Gutenberg so much. 10 yrs of experience.

Need some custom developer help? Let me know

Follow Misha

Need some help with WooCommerce?

If you need some professional developer help, I will be happy to assist you.

Contact me Who I am?

Leave a comment

php js HTML CSS Code

I will only use your personal information to contact you. Privacy Policy