I’m trying to add a custom button or two to the TinyMCE rich text editor. The tutorials I’ve seen so far are either outdated or explain how to do it with a custom plugin. How can I do this without creating a plugin, perhaps in the functions.php
file instead? To be specific, I want to add a “h2” button that will add in a <h2></h2>
into the body.
Leave a Reply
You must be logged in to post a comment.
It is almost code golf, but this is the smallest piece of code that I could up with that will create a button on the Visual editor to turn the current paragraph in a
<h2>
block.It is based on a TinyMCE code sample and uses a trick to pass a function as the
setup
variable (which will not be needed in 3.2 anymore).To add a button to the HTML editor you can extend the much simpler “quicktags” code by enqueuing this extra Javascript file: