WordPress.org

Support

Support » How-To and Troubleshooting » Current page id outside the loop

Current page id outside the loop

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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

    $wp_query->post->ID

    especially if you are going to be doing this outside of the loop.

    Ryan S

    @ryan_accuwebhosting

    I have once used $wp_query->post->ID, and it worked fine. But I am still not sure about it..

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Current page id outside the loop’ is closed to new replies.