Is there a better, more efficient way to get the post id outside the loop?
An alternative to your way would be to access the $post global: global $post echo $post->ID; But It won’t make a noticeable difference, either way If you want to increase efficiency, you ought to be looking elsewhere… EDIT, pertaining to comments: what about get_the_ID();? –> Needs to be run inside the Loop. i have tried … Read more