I\'m creating a meta box for my custom post type. There are multiple fields where I would like to use wysiwyg editor rather than . Is is possibl
// for custom post type
function wo_second_editor($post) {
echo "<h3>Write here your text for the blue box on the right:</h3>";
$content = get_post_meta($post->ID, 'wo_blue_box' , true ) ;
wp_editor( htmlspecialchars_decode($content), 'wo_blue_box', array("media_buttons" => false) );
}
add_action('edit_form_advanced', 'wo_second_editor');
function wo_save_postdata($post_id, $post, $update) {
//...
if (!empty($_POST['wo_blue_box'])) {
$data=htmlspecialchars($_POST['wo_blue_box']);
update_post_meta($post_id, 'wo_blue_box', $data );
}
}
add_action('save_post', 'wo_save_postdata');
// Theme:
<div class="blue">
<?php
$content = get_post_meta(get_the_ID(), 'wo_blue_box' , true );
$content = htmlspecialchars_decode($content);
$content = wpautop( $content );
echo $content;
?>
</div>
This did the trick for me:
http://www.farinspace.com/multiple-wordpress-wysiwyg-visual-editors/
It's basically creating your textarea with an id, then calling from js:
tinyMCE.execCommand('mceAddControl', false, 'your_textarea_id');
Hope it helps!
First install TinyMCE Advanced plugin. Second add "theEditor" class to your textarea like this
<textarea class="theEditor" name="custom_meta_box"></textarea>
Thats it ;)
Nabeel
Try the custom field template plugin http://wordpress.org/extend/plugins/custom-field-template/
http://codex.wordpress.org/Function_Reference/wp_editor was by far the easiest method I found, built into Wordpress since 3.3 (so upgrade ;-) )
But you need to replace presentation with nl2br() function as textarea in custom templates have the toogle JS issue, that removes all your <P>
and <br/>
tags and therefore all line breaks.