wordpress snippets last updated   : October 6, 2014
we now have 641 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!