Add a wp editor to custom plugin and save data

Solved it!

Hope somebody else can use it or it answers their problem. If there is a better way please share and tell why.

$editor_id = 'custom_editor_box';
$uploaded_csv = get_post_meta( $post->ID, 'custom_editor_box', true);
wp_editor( $uploaded_csv, $editor_id );

To save the data:

function save_wp_editor_fields(){
    global $post;
    update_post_meta($post->ID, 'custom_editor_box', $_POST['custom_editor_box']);
}
add_action( 'save_post', 'save_wp_editor_fields' );

And that’s all there is to it!

Leave a Comment