wordpress - how to add WYSIWYG to textarea with a specific class wordpress - how to add WYSIWYG to textarea with a specific class wordpress wordpress

wordpress - how to add WYSIWYG to textarea with a specific class


It depends on where your textarea is located - options page, settings page, meta box?

Say that it's located in an options page, and you have saved option called my_option. First you'd fetch that option:

$my_option = get_option( 'my_option' );

And then you'd call the editor

wp_editor( $my_option , 'my_option', array(    'wpautop'       => true,    'media_buttons' => false,    'textarea_name' => 'my_option',    'editor_class'  => 'my_custom_class',    'textarea_rows' => 10) );

This should display the TinyMCE editor in your textarea.

Check out the codex for wp_editor to see what other arguments you can set.

In case of post or page metabox, you'd save the options in a meta field and get them out with get_post_meta() function.