If I understand correctly the question, the right answer would be to use url_to_postid function.
Then you can setup post id this way:
global $post;
$post = get_post($post_id, OBJECT);
setup_postdata($post);
// your code
wp_reset_postdata();
If I understand correctly the question, the right answer would be to use url_to_postid function.
Then you can setup post id this way:
global $post;
$post = get_post($post_id, OBJECT);
setup_postdata($post);
// your code
wp_reset_postdata();