I believe Facebook uses the Open Graph protocol for this. Basically, a site that provides certain Open Graph meta tags can have the data that these tags refer to appear nicely formatted on Facebook.
Example from the Open Graph protocol site:
<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>
...
</html>
You could probably use a similar approach if this suits your use case.
For sites without these tags, Facebook does indicate that:
Without these tags, the Facebook Crawler uses internal heuristics to make a best guess about the title, description, and preview image for your content.
If your question is centered around how this can be achieved, things might get a little more complicated. You could try an approach in which, based on a WordPress post URL, you perform a GET
request on the associated blog’s REST API that fetches the metadata of that particular post for you.