I think this should be a pretty simple question, but I'm just getting started. Can someone take a look at 3 versions of the same (?) Code below and say what is the difference? They all seem to work fine in the loop I'm working on.
What should I use: $post->ID , $the_ID or get_the_id() ? Do I need to have global $post; ?
global $post; $content = get_post_meta( $post->ID, 'my_custom_field', true ); echo $content;
or
$content = get_post_meta( $the_ID, 'my_custom_field', true ); echo $content;
or
$content = get_post_meta( get_the_id(), 'my_custom_field', true ); echo $content;
Many thanks for your help
source share