Get post ID from a link
I guess you’re not after the current post/page ID, but rather trying to find the ID for some url from your site. Then you should try out the handy url_to_postid() WordPress core function. It returns the post/page ID if it exists, else 0. Example: echo url_to_postid( ‘http://example.com/2014/11/14/hello-world’ ); // Outputs the post ID as 1 … Read more