title: wordpress get post id from side widget
body: <p>I am trying to get the post id from a widget I am putting into the sidebar, but what ever I try I seem to get random post id's from other posts.</p>
  
  <p>I have tried:</p>
  
  <pre><code>            $id = get_the_id();
  
              $post_id = $GLOBALS['post']-&gt;ID;
  
              global $wp_query;
  
              $thePostID = $wp_query-&gt;post-&gt;ID;
  </code></pre>
  
  <p>The template I am using is classipress and I am putting my widget into the sidebar they provide. They already have a form at the top of the sidebar which uses the post id. They use</p>
  
  <pre><code>            global $post;
  </code></pre>
  
  <p>I have tried this also and it too gives my a different post id, but not the correct one.</p>
  
  <p>I am all out of ideas at this stage.</p>