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>';
}
}