I need to add a company name as a category. It needs to have a superscripted registered trademark element next to it. However, it seems that WordPress strips the HTML tags: <sup></sup>, or any other HTML tags.

I found reference to allowing HTML tags in category descriptions, posted below:

remove_filter( 'pre_term_description', 'wp_filter_kses' );

...and tried using this in conjunction with single_term_title, single_cat_title but didn't work so obviously I'm referencing the wrong function.

Can anyone please help me figure out the proper WordPress function to allow me enter HTML tags into the category name field? Or is there a better way to achieve the same result?

Right now I need to stick to adding this into the functions.php file, no plug-ins please.


As of WordPress 4.6, it's not possible to save html in the category name field.

Technical Reason

When categories (or any taxonomy for that matter) are saved, wp_update_term() runs and passes the values through sanitize_term() which strips out any html.

$args = sanitize_term($args, $taxonomy, 'db');

Alternative Solution

I'm not sure how you're displaying category names on your site, but here's an example where you can append the <sup> html on the fly.

Replace the 'Superscripted Company Name' with whatever the company name is you're trying to add the <sup> to.

 $categories = get_categories();

 foreach( $categories as $category ) {

   if ( false !== stripos( $category->name, 'Superscripted Company Name' ) ) {
     $category->name . '<sup>tm</sup><br>';
   } else {
     echo $category->name . '<br>';


Note: Since the company name is hardcoded, anytime you change it, you'll need to update this code as well. A safer solution would be to use the $category->term_id instead of the $category->name since that should never change.

Safer Solution

You'll first need to find the category id of the company you want to add the <sup> to. Then replace the '396' number below.

 $categories = get_categories();

 foreach( $categories as $category ) {

   if ( 396 == $category->term_id ) {
     echo $category->name . '<sup>tm</sup><br>';
   } else {
     echo $category->name . '<br>';

| improve this answer | |
  • 1
    I tried your "safer solution" and was able to get it to work. Thank you!!! – dandruff89 Nov 3 '16 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.