SyntaxFix
Write A Post
Hire A Developer
Questions
Use this global $post instead:
global $post; echo $post->ID;