admin管理员组文章数量:1332889
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?
本文标签: phpTrying to get post ID outside loop on blog page
版权声明:本文标题:php - Trying to get post ID outside loop on blog page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742309824a2450642.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论