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