Title: wp_editor
Last modified: May 23, 2017

---

# wp_editor

 *  [guylancaster](https://wordpress.org/support/users/guylancaster/)
 * (@guylancaster)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/wp_editor-3/)
 * I would like wp_editor (or similar) to return a string to be inserted in the 
   rest of the code in my plugin/short code.
 * I want the user formatting, but don’t want something that prints/echos when called.
 * Any ideas apreciated

Viewing 1 replies (of 1 total)

 *  [goldhat](https://wordpress.org/support/users/goldhat/)
 * (@goldhat)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/wp_editor-3/#post-9161626)
 * I don’t know of an alternative to wp_editor that returns the output. There probably
   isn’t one because the editor is a lot of different stuff, JS files get loaded
   to support it, it’s probably a mixture of templates and JS to render as well.
   Anyway the solution I’d use is PHP output buffering with ob_start(), ob_get_contents(),
   ob_end_clean(). What this does is allow you to store the output rather than have
   it print/echo out immediately. It’s a valuable tool to know as well because it’s
   used all the time in template output, when template files are loaded often the
   file is required/included but the code is stored with output buffering and printed
   later.
 *     ```
       ob_start();
       wp_editor( $settings );
       $editor = ob_get_contents();
       ob_end_clean();
       ```
   
 * At this point you have all the code stored in the variable $editor, print it 
   when/where you need it. I haven’t actually tried this with wp_editor() but in
   principle it should work unless there is some complication involving the javascript.
 * For reference and more details see answer at [https://stackoverflow.com/questions/4401949/whats-the-use-of-ob-start-in-php](https://stackoverflow.com/questions/4401949/whats-the-use-of-ob-start-in-php)
    -  This reply was modified 9 years, 2 months ago by [goldhat](https://wordpress.org/support/users/goldhat/).
    -  This reply was modified 9 years, 2 months ago by [goldhat](https://wordpress.org/support/users/goldhat/).
    -  This reply was modified 9 years, 2 months ago by [goldhat](https://wordpress.org/support/users/goldhat/).

Viewing 1 replies (of 1 total)

The topic ‘wp_editor’ is closed to new replies.

## Tags

 * [output buffering](https://wordpress.org/support/topic-tag/output-buffering/)
 * [wp_editor](https://wordpress.org/support/topic-tag/wp_editor/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 1 participant
 * Last reply from: [goldhat](https://wordpress.org/support/users/goldhat/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/wp_editor-3/#post-9161626)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
