Retrieve id of page/post given its url, or zero on failure. Can be thought of as the opposite function of get_permalink().
When using this function to retrive the ID of an attachment, it is required that the url provided be in the format of example.com/?attachment_id=N and will not work with the full URL. To get the id from the full URL see this for a work around.
The function first checks for if the URL contains the ID of the item. If it doesn't it then does a in depth determination. However this requires Rewrite Rules to be enabled.
<?php $postid = url_to_postid( $url ); ?>
url_to_postid() is located in