I have created a meta field in the new post page. When I add some content in the meta field, I store it in a hidden textarea.

When a post is saved, I want to clear all content of the editor and copy the data of that meta field textarea to the editor.

The data can be copied with jQuery, however I'm unable to figure out that how I send it to the editor just before saving the post?

The idea is build a visual shortcode, and the data being sent to the editor will be shortcode.

I will really appreciate any help in this regard.

1 Answer 1


Assuming you refer to the WP main editor, you can get the TinyMCE instance with

var mainEditor = tinyMCE.getInstanceById('content');

then clear the current content with:


and add your new content

mainEditor.setContent('we are the borg lower your shields and surrender your ships');

If the new content doesn't get saved, call



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.