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 <textarea>
. Is is possible to add multiple editors to a meta box?
I would really appreciate your help!
Many thanks. Dasha
Here is full code example:
add_action( 'add_meta_boxes', function() {
add_meta_box('html_myid_61_section', 'TITLEEEEE', 'my_output_function');
});
function my_output_function( $post ) {
$text= get_post_meta($post, 'SMTH_METANAME' , true );
wp_editor( htmlspecialchars($text), 'mettaabox_ID', $settings = array('textarea_name'=>'MyInputNAME') );
}
add_action( 'save_post', function($post_id) {
if (!empty($_POST['MyInputNAME'])) {
$datta=sanitize_text_field($_POST['MyInputNAME']);
update_post_meta($post_id, 'SMTH_METANAME', $datta );
}
});
Forget adding custom codes, use Advanced Custom Fields, it's excellent and simplify your life.