Support » Fixing WordPress » Current page id outside the loop
7 years, 11 months ago
How can I write current page ID outside the loop?
7 years, 9 months ago
Should be just $post->ID but if you get it working let me know… when I do this it keeps returning a number that is incorrect.
while $post->ID should work it’s a better idea to use
especially if you are going to be doing this outside of the loop.
I have once used $wp_query->post->ID, and it worked fine. But I am still not sure about it..