Skip to main content
1 of 5
birgire
  • 67.8k
  • 7
  • 119
  • 251

I guess you're not after the current post ID, but rather trying to find the post ID for some post url from your site.

Then you should try out the handy url_to_postid() WordPress core function.

Example:

echo url_to_postid( 'http://example.com/2014/11/14/hello-world' );
birgire
  • 67.8k
  • 7
  • 119
  • 251