I'm trying to add a rich text editor to my own plugin. So I googled it first of course and I found several answers on dev4press and Stack Overflow. This code displays nothing so I tried another solution. This displays a rich text editor like :

enter image description here

This seems to work fine, but as soon I switch to the WYSIWYG tab the text I inserted is deleted, I only see a blank field and I can't type anything.

Is someone familiar with this problem? Is this a bug or what can I do to make it work?

These scripts and styles are included in my plugin:

function highlights_style() {

function highlights_script() {
    wp_register_script( 'jquery.js', HIGHLIGHTS_PLUGIN_URL . 'jquery.js', array('jquery','media-upload','thickbox'));
    wp_enqueue_script( 'jquery.js' );

    wp_enqueue_script( 'editor' );


    add_action( 'admin_head', 'wp_tiny_mce' );

And I use this to display the editor:

the_editor( '' , 'content' );

4 Answers 4


wp_editor() outputs the textarea(html codes), so, maybe you dont need to use that in functions.php, but use inside the page's source. (for example, in your plugin.php:

<div class="blabla>
  <form action="" method="POST">
  <?php wp_editor( 'Hi,its content' , 'desired_id_of_textarea', $settings = array('textarea_name'=>'your_desired_name_for_$POST') ); ?> 
  <input type="submit">

note: it may wont work for add_option function..


I suggest you use the built in wp_editor() function. Google "wp_editor wordpress codex" and Check out this tutorial Using the WP Editor Function

  • I'll tried this, added the wp_editor. But still having the same 'bug'.. Someone who can help me? @i-4Web Current code:add_action( 'edit_page_form', 'content' ); wp_editor( "Sample", 'content', array( 'textarea_name' => 'content' ) );
    – Ronny Rook
    Commented Apr 22, 2013 at 21:26

You have unnecessary scripts loading.

You are able to see the editor.. but it is not loading it's javascript. You can tell because there are no buttons present. This is most likely because you have a javascript error.

I would remove the unnecessary scripts you have enqueued.

Then, check your browser console to see what errors or notices are generated.


to properly use the wp_editor use it like this:

// add the admin settings and such
add_action('admin_init', 'wp_your_plugin_admin_init');
function wp_your_plugin_admin_init(){
register_setting( 'wp_your_plugin_settings', 'wp_your_plugin_settings', 'wp_your_plugin_settings_validate');
add_settings_field('wp_your_plugin_user_custom_text', __('Enter your message','wp_your_plugin'), 'wp_your_plugin_user_custom_text', 'wp_your_plugin', 'wp_your_plugin_main');

function wp_your_plugin_user_custom_text() {
$options = get_option('wp_your_plugin_settings');
$settings  = array('media_buttons' => true,'textarea_rows' => 5,'textarea_name' => 'user_custom_text');
wp_editor( $options['user_custom_text'],'user_custom_text', $settings  );}  

// validate  
function wp_your_plugin_settings_validate() {
$options = get_option('wp_your_plugin_settings');

if ( empty($_POST['user_custom_text']) ){
    $options['user_custom_text'] =  __('Enter your own content, it will be below the original message','wp_your_plugin');// as set when the plugin activated
    $options['user_custom_text'] =  wp_kses_post($_POST['user_custom_text']) ;}// u need to Sanitize to be able to get the media to work

Your Answer

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

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