Using wp_editor in shortcode

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
ob_start();

// Echo the editor to the buffer
wp_editor();

// 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;

Leave a Comment