How to store the third party script with HTML code in the wordpress custom input field?

You are using esc_textarea() to output the content – so it’s doing exactly that. This is of course the correct thing to do with user input, so you have a few options here. Only ask for the embed id – then reconstruct it in php. Something like: <!– Meta box input example –> <input name=”thirdpartyvideoscript” … Read more

update_post_meta

I don’t think you’re actually getting the post ID sent by the javascript. function toggle_task_status () { $post_id = $_POST[‘data’][‘post_id’]; $update = update_post_meta($post_id , ‘task_status’, ‘open’); if($update){ wp_send_json(‘success’); } else { wp_send_json(‘fail’); } wp_die(); } and then in your javascript success: function (response) { console.log(response); // should be either ‘success’ or ‘fail’ }