获取当前帖子的 WordPress 帖子 ID [英] Getting the WordPress Post ID of current post
本文介绍了获取当前帖子的 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();
这篇关于获取当前帖子的 WordPress 帖子 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文