Friday, July 30, 2010
 

Get the post id outside the loop

Small wpx function to retrieve a wordpress post id, outside the loop. Copy the following code to your functions.php file.
function wpx_postID(){
global $wp_query;
return $wp_query->post->ID;
}

You can now retrieve the ID by calling wpx_postID()

 

Comments

No comments so far.
  • Leave a Reply
     
    Your gravatar
    Your Name