获取当前帖子的 WordPress 帖子 ID
问题描述:
有谁知道如何获取当前页面的帖子ID?
Anyone know how I can get the post ID of the current page?
所以,如果我在某个特定的帖子上,在我的 header.php 中,我希望能够获得当前的帖子 ID.
So, if I'm on a particular post, inside my header.php, I want to be able to get the current post id.
谢谢!
答
试试这个:
$id = get_the_ID();