Powered By Blogger

Friday, July 29, 2022

Add wysiwyg editor in WordPress meta box for custom post type or Posts

 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_decode($text), 'mettaabox_ID', $settings = array('textarea_name'=>'MyInputNAME') );
} add_action( 'save_post', function($post_id) { if (!empty($_POST['MyInputNAME'])) { $datta=htmlspecialchars($_POST['MyInputNAME']);
update_post_meta($post_id, 'SMTH_METANAME', $datta ); } });

No comments:

Post a Comment