Getting the post ID from a WordPress content on an external site

In case you need to get the post/page/{$custom_type} ID from a WordPress content, from a remote site or no direct access to the database, here’s an easy and reliable way to do it.

When you make a request to a WordPress site for a “singular” content (that is, the detailed view of a single post, whatever type it is), you should receive a Link HTTP header that uses the database ID of the content, something like:

Link: <https://some-site.com/?p={$POST_ID}; rel=shortlink

From then on, you can extract the {$POST_ID} param from the URL using your favourite technique.

If you do have access to the database, you might want to check this post: How to Get Post and Page IDs in WordPress.