X

How to Add Subscript and Superscript Buttons to Editor

Snippets by IsItWP

Are you looking for a way to add subscript and superscript buttons to WordPress editor? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add subscript and superscript buttons to editor.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function enable_more_buttons($buttons) {
  $buttons[] = 'sub';
  $buttons[] = 'sup';
  return $buttons;
}
add_filter("mce_buttons_3", "enable_more_buttons");

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 20 best WordPress church themes for expanding the flock and how to start a blog.

Comments   Leave a Reply

  1. Thomas Greenbank March 2, 2020 at 4:01 am

    When I try this I get “syntax error, unexpected end of file”

    1. You may want to check that the whole snippet was copied.
      Be sure to check out: https://www.isitwp.com/properly-add-code-snippets-wordpress-site/

  2. It is not working with the Elementor’s editor

    1. Sadly this snippet is not designed to work with Elementor and will most likely only work with the classic editor.

  3. Stephanie Boucher May 15, 2019 at 8:37 am

    This no longer seems to work. Any idea why?

    1. Commented this elsewhere, but just incase:

      For Anyone looking at this using WordPress on a version later than 3.9 that has TinyMCE 4 the function above won’t work, this is because WordPress and TinyMCE changed ‘sup’ to ‘superscript’ and ‘sub’ to ‘subscript’ – If you make those changes in the code above it will work fine!

  4. I am getting a Missing argument 1 for enable_more_buttons() error

  5. Nguy?n Trung D?ng March 11, 2013 at 11:52 pm

    you saved my day man

  6. thanks fot tip

  7. Just what I was looking for!

  8. Donald G. McGahan January 10, 2013 at 11:13 pm

    When I add it, I get a

    Fatal error: Call to undefined function add_filter()

  9. Perfect little piece of code! Works brilliant. Thanks a lot!

    1. No problem glad that I could help!

  10. thanks guys.  i was working with a PhD client today who writes research
    reports and it was necessary for her to sup and sub references.  this
    was key.

    1. Perfect Jerry glad to hear you got things working well.

  11. (text translated by the program)
    Thank you for providing this code, but no need to repeat the array code, simply separate the items in the array

    function enable_more_buttons($buttons) {
    $buttons[] = ‘sub , sup’;
    return $buttons;
    }
    add_filter(“mce_buttons_2”, “enable_more_buttons”);

    1. This is true, I just find this method easier to read. Thanks for the input though people will find this very useful.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!