Menu Close

WooCommerce: Rename “Tags” Label @ Single Product Page

default

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.

WooCommerce: rename “tags” into something else

PHP Snippet: Rename “Tags:” @ WooCommerce Single Product Page

/**
 * @snippet       Rename "Tags" into "Brands" @ WC Single Product Page
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WC 5
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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;
}
View Source
Posted in WooCommerce Tips