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 am building a plugin for frontend submission. I am using shortcodes API to display the form for content submission, but I am having troubles. The problem is, wp_editor echoe's data, and shortcode should return data. When I integrate wp_editor like this:

$final_form .= wp_editor();

form does render, but not in the place but on top of the post content, where shotcode is included. Do you have any idea how would one use wp_editor in shortcode API? I don't wan't to bother with manually calling TinyMCE etc.

Thank you.

share|improve this question
up vote 12 down vote accepted

If a function echos data, you can use php output buffering to capture the echoed output and return it instead

// Turn on the output buffer

// Echo the editor to the buffer

// Store the contents of the buffer in a variable
$editor_contents = ob_get_clean();

// Return the content you want to the calling function
return $editor_contents;
share|improve this answer
Thank you for suggestion. Could you show me an example code? – OriginalEXE Sep 26 '12 at 14:56
see edit above. – Milo Sep 26 '12 at 15:26
Thank you very much for your help! – OriginalEXE Sep 26 '12 at 15:32
Isn't there a get_wp_editor() function? The output buffering looks a bit "hacky". – Ciprian Jan 3 '13 at 13:25
Thanks @Milo. I hope they'll add the option to return it instead of echoing it, without using output buffering. I'm using it for a front-end textarea. – Ciprian Jan 3 '13 at 21:48

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.