Jun
19
2013

Add TinyMCE Editor Anywhere

I had a difficult time finding a way that actually worked to add the TinyMCE editor used in the wp-admin area to textareas for my custom wordpress plugins, but after MUCH yelling, imaginary hair pulling, and some clever miracles, this is how you can add the tinymce editor to any textarea within wordpress (cheering!)

add_filter( 'wp_head','add_tinymce_editor' );
function add_tinymce_editor()
{
    wp_admin_css('thickbox');
    wp_enqueue_script('post');
    wp_enqueue_script('media-upload');
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-tabs');
    wp_enqueue_script('tiny_mce');
    wp_enqueue_script('editor');
    wp_enqueue_script('editor-functions');
    add_thickbox();
}

After which you simply call the wp_editor instead of typing out a textarea, wherever you want it!

<?php wp_editor( $value_to_return, 'textareaname', array( 'textarea_name' => 'textareaname', 'teeny' => true ) ); ?>

3 Comments + Add Comment

  • This is great, exactly what i need … I think.

    Can you explain to a non-coder where i put the snippets?

    Thank you!

    • Sure, you put the “tinymce hooks” section in your theme’s functions.php file, and the wp_editor part below that wherever you’d like the editor to show up

  • Very great tip !
    Thanks for sharing and my best regards to the imaginary hair !

Leave a comment