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
评论列表(0条)