我认为这一定是非常基本的问题,但我只是开始.有人可以查看下面相同(?)代码的3个版本,并说明有什么区别?所有这些似乎都在我正在研究的循环中正常工作.
哪个应该使用:$post->ID,$the_ID或get_the_id()?有必要global $post;吗?
global $post;
$content = get_post_meta( $post->ID, ‘my_custom_field', true );
echo $content;
Run Code Online (Sandbox Code Playgroud)
要么
$content = get_post_meta( $the_ID, ‘my_custom_field', true );
echo $content;
Run Code Online (Sandbox Code Playgroud)
要么
$content = get_post_meta( get_the_id(), ‘my_custom_field’, true );
echo $content;
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助