get_the_id vs. post->ID vs. the_id / get_post_meta get_the_id vs. post->ID vs. the_id / get_post_meta wordpress wordpress

get_the_id vs. post->ID vs. the_id / get_post_meta


If you're inside a WordPress loop, then $post->ID it's the same as using get_the_ID()

You shouldn't need to globalize $post since it's already in the scope of a WordPress loop.

I've never seen code using $the_ID, so I would avoid using that.

The safest choice would be to use get_the_ID()