wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Get post ID outside of loop

wordpress snippet

Adding this PHP code snippet to your single.php will return the current post ID.

snippet :  PHPcopy
       global $wp_query;
       $postID = $wp_query->post->ID;

Did you like this post? If so please share it with your friends. Thanks!