A #CustomizeWoo student reached out for premium support in regard to “WooCommerce taxonomies”. The question was: How do I change the label “tag” into something else, for example “brand”? Well, this is how it’s done!
Please note that this does not change the “tag” permalinks (URL, slug, etc), but only the “Tags” label on the frontend, and only on the Single Product Page.
PHP Snippet: Rename “Tags:” @ WooCommerce Single Product Page
/**
* @snippet Rename "Tags" into "Brands" @ WC Single Product Page
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WC 5
* @community https://businessbloomer.com/club/
*/
add_filter( 'ngettext', 'bbloomer_translate_tag_taxonomy', 9999, 5 );
function bbloomer_translate_tag_taxonomy( $translation, $single, $plural, $number, $domain ) {
if ( is_product() && 'woocommerce' === $domain ) {
// This will only trigger on the WooCommerce single product page
$translation = ( 1 === $number ) ? str_ireplace( 'Tag:', 'Brand:', $translation ) : str_ireplace( 'Tags:', 'Brands:', $translation );
}
return $translation;
}
Thanks for the tip. I tried but it is not work for my site too.
My site’s default language is Simplified Chinese. i add the code to my functions.php, i try to chang tag(标签)to special(特色),after add it is the same, nothing is change
Try with this instead? https://www.businessbloomer.com/translate-single-string-woocommerce-wordpress/
thx,i just change woocommerce-zh_CN.po translate character to fix the problem ,but still thx again!
Cool
Thanks for the tip. I tried but not work for my case.
My site’s default language is Traditional Chinese. If I add below script where XXXX is the string in my default language
$translated = str_ireplace(‘tag’, ‘XXXX’, $translated);
then I have two problems:
1. From the product page, it shows XXXXs: ….., there is no singular and plural form to the string in Traditional Chinese.
2. English is my second language, I don’t know how to translate XXXX back to English, I can’t find the string from WPML String Translation because it has not to be registered.
, then the display from product page
Tried the latest version already?
How to get this done for Product Brand?
Hi Ashwini, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Thanks, everything worked for me. Translated the product tag into English and French : tag and Étiquettes to “condition” (for a vinyl shop). Did this in the main theme function.php but will have to learn how to implement this to a child theme. Site will be online soon.
Nice!
No. Its not working and im getting 503 error.
Hi, Im sorry, the code is running fine. Only after i read other comments, where we could not use code snippet plugins.
Thanks. keep the good work
Great!
Hello, I am trying to change the “Category” name to “Personality” on the single product page. I used the same code you provided above, but swapped out “Tag” for “Category” and “Brand” to “Personality” but nothing has happened.
Should the same code work? Or should;d I try something else?
Hi Evan, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Re: “Oh no! I just copied and pasted your code into my Snippets Plugin and it took down the site. Now I have a 500 error and can’t get back in to even remove it. Can you help?”
I too had issues with this snippet (I got memory exhausted errors). I have tried SEVERAL suggested code sippets trying to find ONE which allowed me to change the “SKU” text on the single product page to read “Model #”. I got this one to work using, (using the Code Snippets plugin) but it required a small modification to get it to work.
Basically I removed the “if” condition and used the following code instead:
/*Begin Code*/
/**
* @snippet Rename “Tags” into “Brands” @ Single Product Page – WooCommerce
* @how-to businessbloomer.com/woocommerce-customization
* @sourcecode https://businessbloomer.com/?p=21598
* @author Rodolfo Melogli, Business Bloomer
* @compatible WC 3.4.3
*/
add_filter(‘gettext’, ‘bbloomer_translate_tag_taxonomy’);
add_filter( ‘ngettext’, ‘bbloomer_translate_tag_taxonomy’ );
function bbloomer_translate_tag_taxonomy($translated) {
$translated = str_ireplace(‘SKU’, ‘Model #’, $translated);
return $translated;
}
/*EndCode*/
Once I removed the “if” statement the error went away and “SKU” was relabeled to “Model #” as I wanted.
For anyone using the Code Snippets plugin (or one like it, you will need to inactivate the offending snippet by deactivating it at the database level. (basically find the row in your snippets table with the offending snippet and set it to inactive should bring your site back up)
“Using Code Snippets is not ideal because you can’t access the code directly and “switch it off” – I recommend you look into creating a child theme instead. Anyway, via FTP, go to the plugins folder and rename the Code Snippets plugin folder temporarily – your site will come back up. Let me know”
FYI, I AM using Code Snippets with a child theme because it allows me to manage ALL of my code snippets in a VERY easy to use interface. I used to create mini plugins with my snippets so that I could easily turn them on or off as needed for debugging or retiring snippets. Now without without requiring FTP or the theme editing, I can turn code snippets on and off with the Code Snippets plugin. The plugin also does not limit me to JUST PHP code snippets, I can also use this for javascript and CSS snippets as well. It also gives me options for organizing my snippets that I didn’t quite have when truning them into mini plugins.
Thanks for your feedback 🙂
Oh no! I just copied and pasted your code into my Snippets Plugin and it took down the site. Now I have a 500 error and can’t get back in to even remove it. Can you help?
Sorry to hear that Deby, my snippet works so you have some other sort of issue. Using Code Snippets is not ideal because you can’t access the code directly and “switch it off” – I recommend you look into creating a child theme instead. Anyway, via FTP, go to the plugins folder and rename the Code Snippets plugin folder temporarily – your site will come back up. Let me know
Hey Rodolfo, me again, it’s working to a point… The client wishes to have the word “For” instead of “Tags” but there is an ‘s’ added so now it says “Fors”… any thoughts on that?
Hello Rochelle – thanks so much for your comment! Yes – try to translate “tags” and not “tag” – that will work 🙂
Hooray!
A few days of hunting for something that would work for me and this did the job. I needed to change the category taxonomy name and so replaced “tag” with “category” and viola.
Thank you very much!
Excellent 🙂
I tried to replace tag with category and it did not work. Any ideas why? Thank you for your great website!
Try with “Category: ” instead and let me know!
Enjoying your videos and WooCommerce modification and a lot of it has worked out great! Not sure why this doesn’t work; tried on two (development) sites on two different servers. The only way I’ve had success is by copying meta.php to the child theme – the totally ugly way to do it. The parent theme didn’t have this file and I also tried using twenty-seventeen theme, but still no luck. Added your the code to the child theme functions.php. Am using Avada and notice they have their own set of WooCommerce hooks. https://theme-fusion.com/documentation/avada/special-features/remove-woocommerce-overrides-avada/ but nothing for changing the ‘Tag’.
Hey Rochelle, thanks so much for your comment! I’ve revised the snippet, give it a go 🙂
I still can’t change it pls. I want to rename it from /tag/ to /artist/
Hey Richard, thanks for your comment! I think this renames the label and not the URL/slug. Sorry 🙂
Thanks! works great at my site. I was trying to translate it to spanish “Brand” (marca), and with this snippet I have done it in just a minute.
Cheers
Marius
Brilliant 🙂 Thank you Marius!