metabox - Getting gutenberg (WordPress 5) to save TInymce data?

admin2025-06-05  2

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!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749098290a316346.html

最新回复(0)