WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I managed to get the #content field html with this jquery call:


This seems to be failing though on "Add New Post" pages. Any tips on how to get the contents of the #content div?


share|improve this question
It seems there is no div#content within the Add New Post page! – Hamed Momeni Nov 16 '11 at 13:49
I can see it <div id='editorcontainer'><textarea rows='20' class='theEditor' cols='40' name='content' tabindex='2' id='content'></textarea></div> – giorgio79 Nov 16 '11 at 13:55
up vote 0 down vote accepted

The div #editorcontainer contains a regular textarea #content and an iframe #content_ifr.

The #content is filled with the saved contents of the post when the page loads. This means that any live edits of the content won't be returned when calling jQuery("#content").html(). For the same reason, you get an empty string in the case of a new post.

Where you really need to look for the live updated contents is in the iframe, which is used by the WYSIWYG editor. Here's how:


Also see: jquery/javascript: accessing contents of an iframe.

share|improve this answer
Much appreciated. Noticed this works as well tinyMCE.activeEditor.getContent(content) Wonder if there is a universal solution, as there is a CK Editor plugin as well wordpress.org/extend/plugins/ckeditor-for-wordpress – giorgio79 Nov 16 '11 at 14:48
@giorgio79: doesn't work for me. Returns NULL. Also if I try tinyMCE.activeEditor.getContent(content) it gets an error saying activeEditor is null do i have to enqueue any script? – Sisir Dec 15 '12 at 7:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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