Support » Fixing WordPress » Getting Post ID outside of loop keeps returning Page ID

  • Resolved ranji77

    (@ranji77)


    I have no idea what’s happening. I am trying to get Post ID’s outside of the loop with:

    global $wp_query;
    $thePostID = $wp_query->post->ID;
    
    echo $thePostID;

    yet, it keeps returning the page ID that I’m using as a template page instead.

    Any ideas? Thank you!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Getting Post ID outside of loop keeps returning Page ID’ is closed to new replies.