I want to add a button to tinyMCE editor on new post page. With this toturial I managed to get the button work perfectly, but there is something I couldn’t figure out. When you insert a “More” tag, an image will appended to the html with appropriate ‘background-image’. See screenshot bellow:
But when you switch to ‘Text’ mode there is a html comment like this: <!--more-->
.
I could add the image in the html but on ‘Text’ mode there is an img
tag.
I want to have something like this: <!--my-custom-tag-->
How wordpress manage to do this? Or how could I append a custom tag on tinyMCE editor?
I found the answer. You need to add
BeforeSetContent
andPostProcess
events on the editor object (As I mentioned earlier, first follow this toturial to add your button):Or you can make a shortcode. I use it always you can write you’re own code so you understand it. Little to no writing in jQuery from tinymce!
example
https://codex.wordpress.org/Function_Reference/add_shortcode