2
votes

I am trying to setup a custom post type in WordPress that contains a textarea that I want to turn into a TinyMCE WYSIWYG editor. The second-to-last post on this thread shows how to embed JavaScript that will call TinyMCE on the text editor. However, when I try to use it, I get a JavaScript error that tinyMCE is not defined.

It looks like the problem is that because the post type doesn't have content, the editor JavaScript (which includes the global tinyMCE object) isn't being included in the admin page. How do I include these scripts so that I can then access tinyMCE?

Thanks,

-Nate

1
yepp, tiny_mce.js needs to be loaded on that page - Thariama
So what's the best way to do that through WordPress's hooks / actions? It's an admin page, so it's not as though I can simply include the JavaScript file, right? - Nathan Rutman
that's true afaik, unfortunatly i do not know how to make that work in wordpress - Thariama

1 Answers

0
votes

Maybe you can use wp_editor. See other references in WordPress Answers.

For testing, I had the CPT defined without an editor: 'supports' => array( 'title', 'comments' ).

And used this Custom Meta Box:

add_action( 'add_meta_boxes', 'add_custom_box_so_14611445' );

function add_custom_box_so_14611445() 
{
    add_meta_box( 
        'sectionid_so_14611445',
        __( 'Custom Editor' ),
        'inner_custom_box_so_14611445',
        'portfolio' 
    );
}

function inner_custom_box_so_14611445( $post ) 
{
    echo wp_editor( '', 'editor_id_so_14611445', array() );
}