The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Current page id outside the loop (4 posts)

  1. levani01
    Posted 7 years ago #

    How can I write current page ID outside the loop?

  2. ittekudasai
    Posted 7 years 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.

  3. Creative Slice
    Posted 7 years ago #

    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.

  4. Ryan S
    Posted 7 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.