Multiple TinyMCE Editors in WordPress Custom Posts
This is a small update to my Custom Posts series which explained how to create your own custom posts.
For my custom posts I needed multiple editor boxes as there are different large areas of text to fill. Pre WordPress 3.3 I had to do this in a really clunky way with the addition of another plugin and I just wasn’t happy with it.
However, there is a massive big gleaming light at the end of the tunnel as WordPress 3.3 supports multiple instances of its default editor (TinyMCE) on the same page. All it takes are a few lines of code.
- We need to preload (simple one liner)
add_action( 'admin_print_footer_scripts', 'wp_preload_dialogs');
- We need to load tinyMCE
function pluginLoadTinyMCE {
wp_tiny_mce();
}
- Call the editor (another simple one liner)
<?php wp_editor( $value, 'name', $settings = array() );?>
Just surround this editor in whatever html you need and grab the POST[‘name’] variable. The editor will appear just like any other editor in default WordPress pages.
Useful Links wp_editor function reference