php - Trying to get post ID outside loop on blog page

I have a blog index page which only lists 1 custom post at a time on the index page (it is paginated). I am trying to ge

I have a blog index page which only lists 1 custom post at a time on the index page (it is paginated). I am trying to get the ID of that post from outside the loop (in the footer, after the loop) but am unable to do so. When I call it, i get the ID of the next post not the current one.

global $post;
echo $post->ID;  // return ID of the next post, not the current one. not sure why.

I know that this is an unusual setup (my index page is basically a single post page). Should I change my index page design, or is there a simple way for me to just get the current post ID without throwing away all my current work?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742309825a4419666.html

相关推荐

  • php - Trying to get post ID outside loop on blog page

    I have a blog index page which only lists 1 custom post at a time on the index page (it is paginated). I am trying to ge

    14小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信