2

I've created a custom metabox area and need to add the option of multiple metaboxes.

So far I found this guide https://jeremyhixon.com/repeating-wordpress-editor/ which works absolutely perfect up until one point.

When you click to add a new metabox it dynamically adds the textarea and turns it into a tinyMCE using

tinymce.init({ selector: '#' + contentID });

However, this tinyMCE widget looks completely different and also doesn't include the media buttons which I really need here.

Is there any way to make this all possible using this method. If you look at the comments, the guides author is also struggling with this issue.

0

I am not sure if this is what you want: (Source: https://stackoverflow.com/questions/3493313/how-to-add-wysiwyg-editor-in-wordpress-meta-box)

add_action( 'add_meta_boxes', 'adding_new_metaabox' );              
function adding_new_metaabox() {   
    add_meta_box('html_myid_61_section', 'TITLEE Helloo', 'my_output_function');
}

function my_output_function( $post ) {
//so, dont ned to use esc_attr in front of get_post_meta
$valueeee2=  get_post_meta($_GET['post'], 'SMTH_METANAME_VALUE' , true ) ;
wp_editor( htmlspecialchars_decode($valueeee2), 'mettaabox_ID_stylee', $settings = array('textarea_name'=>'MyInputNAME') );
}


function save_my_postdata( $post_id ) {                   
if (!empty($_POST['MyInputNAME']))
    {
    $datta=htmlspecialchars($_POST['MyInputNAME']);
    update_post_meta($post_id, 'SMTH_METANAME_VALUE', $datta );
    }
}
add_action( 'save_post', 'save_my_postdata' ); code here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.