Is this happening on for new post and existing posts, or just new posts.
I’m not sure that the global $post
will always contain what you expect it to. Try outputting what is there to test.
echo '<pre>'; print_r($post); echo '</pre>';
You may need to test for the post type in some other way for new posts.
~JH