Support » Plugins » Howto get the post ID displayed

  • Resolved Laurent Duretz



    I’m working on a sidebar widget and I need to get the page/post id of the page I calculate.

    I can’t une the_ID because the sidebar is outside The Loop.

    I’ve read something like rewind_post() and I’ve to test it.

    Does somebody have another way to retreive this ID ?


Viewing 1 replies (of 1 total)
  • I’m a bit surprised the answer to this question is so difficult to find. Or maybe I don’t know where/how to look. I’ve tried the following function, but it’s not working for in my widget (though it does work for me directly when I hard code it into sidebar.php).

    `// Works in single post outside of the Loop
    function function_name() {
    global $wp_query;
    $thePostID = $wp_query->post->ID;

Viewing 1 replies (of 1 total)
  • The topic ‘Howto get the post ID displayed’ is closed to new replies.