Ensure TinyMCE is loaded for Wordpress (for meta boxes)

/ Published in: PHP
Save to your folder(s)

If you are creating a custom post type in Wordpress, and turn off the 'editor' capability, then TinyMCE is not loaded. This means any WYSIWYG meta box textareas will fail. Add this snippet to your theme's functions.php file to load the required TinyMCE JS and styles.

Copy this code and paste it in your HTML
  1. /**
  2.  * Ensure TinyMCE is loaded.
  3.  * Required to use TinyMCE in meta boxes.
  4.  */
  5. add_action("admin_head","myplugin_load_tiny_mce");
  7. function myplugin_load_tiny_mce() {
  8. wp_tiny_mce( false ); // true gives you a stripped down version of the editor
  9. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.