Help Docs Software Kadence Kadence Iconic Kadence Iconic Show Single Variations Append Trademark After The Product Title

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);
Was this article helpful?