Many blog writers especially those who are writing scientific content on their WordPress websites looking for a way to add subscript and superscript buttons to WordPress editor.
Actually one of my clients is a pathologist and he badly needs to write lab formulas on his website which I have developed for him in WordPress. For example, he wanted to write C6H12O6.
And many of you already know that WordPress is not offering a built-in option for subscript and superscript characters in their editors. For further clarification about how to use subs and sups check Editing Help page in the codex. As per codex page, we have to write inside text view of the editor, something like this; “C<sub>6</sub>H<sub>12</sub>O<sub>6</sub>
“.
I was wondering how to add such an option where he can easily add superscript and subscript characters. I’ve thoroughly checked “Class Editor” features for special characters, but I could not find Subs and Supscript option as that’s missing.
There are some plugins available to facilitate such options inside the built-in editor. But I don’t like extra plugins which cause extra load on the website as well as security issues. I’ve found a code snippet that you can use to add subscript and superscript buttons to the WordPress editor quickly.
Instructions:
All you have to do is add the following function code to the bottom of your theme’s functions.php file.
function enable_more_buttons($buttons) {
$buttons[] = 'subscript';
$buttons[] = 'superscript';
return $buttons;
}
add_filter("mce_buttons_3", "enable_more_buttons");
Filtering mce_buttons_3 means it will display the added buttons on a third line of the editor.
See the following figure where I have encircles the Subscript and Superscript buttons.
The WordPress codex section on enabling hidden MCE buttons, which demonstrates how to filter the button list of the editor.
WordPress uses TinyMCE for the classic editor and if you need more control over the classic editor tools, A full list of buttons is here: http://www.tinymce.com/wiki.php/Controls
Leave a Reply