admin管理员组

文章数量:1130349

I'm using this function to add a tinymce meta box:

add_action( 'add_meta_boxes', function(){
    add_meta_box( 'test_tinymce', 'Test TinyMCE', function( $post ){
         $field_value = get_post_meta( $post->ID, 'test_tinymce', true );
         wp_editor( $field_value, 'test_tinymce_id', array(
            'wpautop'       => true,
            'media_buttons' => false,
            'textarea_name' => 'test_tinymce',
            'textarea_rows' => 10,
            'teeny'         => true
        ) );
    }, null, 'advanced', 'high' );
});
add_action( 'save_post', function( $post_id ){
    if ( ! isset( $_POST['test_tinymce'] ) ) {
        return;
    }
    update_post_meta( $post_id, 'test_tinymce', $_POST['test_tinymce'] );
});

The problem is, WordPress doesn't save this at all. I've seen similar posts on the internet with no resolution.

Any way to get the meta value to save?

Thanks!

I'm using this function to add a tinymce meta box:

add_action( 'add_meta_boxes', function(){
    add_meta_box( 'test_tinymce', 'Test TinyMCE', function( $post ){
         $field_value = get_post_meta( $post->ID, 'test_tinymce', true );
         wp_editor( $field_value, 'test_tinymce_id', array(
            'wpautop'       => true,
            'media_buttons' => false,
            'textarea_name' => 'test_tinymce',
            'textarea_rows' => 10,
            'teeny'         => true
        ) );
    }, null, 'advanced', 'high' );
});
add_action( 'save_post', function( $post_id ){
    if ( ! isset( $_POST['test_tinymce'] ) ) {
        return;
    }
    update_post_meta( $post_id, 'test_tinymce', $_POST['test_tinymce'] );
});

The problem is, WordPress doesn't save this at all. I've seen similar posts on the internet with no resolution.

Any way to get the meta value to save?

Thanks!

本文标签: metaboxGetting gutenberg (WordPress 5) to save TInymce data