Wordpress - Insert html / text in the editor Wordpress - Insert html / text in the editor wordpress wordpress

Wordpress - Insert html / text in the editor


Fixed it myself.

function appendText(text) {//Insert contentparent.tinyMCE.activeEditor.setContent(parent.tinyMCE.activeEditor.getContent() + text);//Close windowparent.jQuery("#TB_closeWindowButton").click();}


For those of you who want to add the text at the current cursor location, you can make use of the mceInsertContent function (built-in TinyMCE function).

A quick example would be:

function addTextIntoEditor(myText){    tinymce.activeEditor.execCommand('mceInsertContent', false, myText);}

This is based on Magus's answer located here