Problem with executing a function on saving a post
The action save_post is also called during AJAX auto-save requests. But your value is not sent then, so you save an empty value for something that isn’t set. Start your save function with: if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; See basic examples with more checks here and here.