Append Trademark After The Product Title

You might want to dynamically add a Trademark symbol or something else after the product or variation title. If that’s the case, the below code snippet can be used to get it done:

/**
 * Append TM after the product title
 *
 * @param string $title
 * @param int $id
 *
 * @return string $title
 */
function iconic_update_post_title( string $title, int $id ): string {
	$allowed_post_ids = array( 1, 2, 3 );
	if ( in_array( $id, $allowed_post_ids ) ) {
		if ( 'product' === get_post_type( $id ) || 'product_variation' === get_post_type( $id ) ) {
			return $title . "TM";
		}
	}

	return $title;
}

add_filter('the_title', 'iconic_update_post_title', 10, 2);

WooCommerce Show Single Variations

Display individual product variations of a variable product in your product listings. Make it easy for your customers to view and filter product variations.

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.