Codex tools: Log in
Retrieve id of page/post given its url, or zero on failure. Can be thought of as the opposite function of get_permalink.
Note that this function does not return the post id for custom post types (see Trac ticket #19744).
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.
<?php $postid = url_to_postid( $url ); ?>
url_to_postid() is located in