WordPress core does not print Open Graph tags — there is no og: string anywhere in its head-output code (default-filters.php, general-template.php); WordPress does not document this either way, but a fresh install with a default theme shows none. Every share preview you have seen from a WordPress site comes from a plugin (Yoast SEO, Rank Math, All in One SEO, Jetpack) or the theme. So "automatic OG images" in WordPress means one of two things: making sure each post has an image the plugin can use, or generating one from the post's title. Here are four ways, from no code at all to a short filter.
First, find out what your site prints today
Open any post, view the page source and search for og:image. You will see one of three things:
- One
og:imagetag — fine; the question is only whether the image is good. - None — no plugin prints Open Graph tags, or the post has no image the plugin can pick. Shared links will show text only or a random image.
- Two or more — the theme and a plugin both print tags. Platforms usually take the first one, which is often not the one you meant. Turn one of them off.
Yoast SEO, for example, picks the social image set in the post's Yoast panel, then the featured image, then an image from the content, then the site-wide default. If none exists, there is no og:image.
Option 1: featured images and a default (no code, no new plugin)
The zero-cost baseline: give every post a featured image, and set a default social image in your SEO plugin (Yoast: Settings → Site basics → Site image; Rank Math: Titles & Meta → Global Meta → OpenGraph Thumbnail) for anything that has none.
Use 1200×630 pixels. That is what Facebook recommends (Meta's image guidelines) and it is above LinkedIn's minimum of 1200×627 (LinkedIn help). The limit of this option is obvious: a person makes every image by hand, and a photo without the title on it says little in a feed.
Option 2: Jetpack Social's Social Image Generator
Jetpack Social can create an image for each post from its title, using predesigned layouts, and recent versions use it as the post's social preview image when you have not chosen one. It is a feature of the paid Jetpack Social plan.
It suits sites already on Jetpack and happy with its layouts. The trade-off is control: the designs are Jetpack's, and the feature is tied to Jetpack's sharing workflow.
Option 3: one pasted snippet, an image for every page
An image service can read each page and render a branded card from its title, description and logo. You paste one snippet — through the free WPCode plugin, so you never open a theme file — and every page gets its own og:image, including pages added later.
With Shareglint's auto-OG URL the snippet looks like this. In WPCode choose Add Snippet → Add Your Custom Code → PHP Snippet, set it to run on the front end, and replace acc_… with your account id from the dashboard:
add_action('wp_head', function () {
global $wp;
$page = is_singular() ? wp_get_canonical_url() : home_url(user_trailingslashit($wp->request));
$image = 'https://shareglint.com/u/acc_….png?url=' . rawurlencode($page);
echo '<meta property="og:image" content="' . esc_attr($image) . '">' . "\n";
echo '<meta property="og:image:width" content="1200">' . "\n";
echo '<meta property="og:image:height" content="630">' . "\n";
echo '<meta name="twitter:card" content="summary_large_image">' . "\n";
}, 1);
Then, in the dashboard, add your domain to the allowed domains — only pages on domains you list get images, so nobody can render cards for other sites on your quota.
What happens next: the first time a crawler requests the image, the service fetches the page, reads its title, description, site name and icon, and renders a 1200×630 card with the domain's template (the built-in site-card, or your own). An unchanged page is served from cache and never costs a second render; tracking parameters like utm_source and fbclid are ignored, so the same post shared with different links is still one image. The Free plan covers 100 new cards a month, with a small badge on the image.
Turn off the SEO plugin's own image so the page has one og:image, not two: in Yoast you can clear the default image and leave posts without a social image, or use the filter in option 4 instead of this snippet.
Option 4: keep your SEO plugin, change only its image (a few lines)
If Yoast or Rank Math already prints good titles and descriptions, replace just the image through their filters. This is code, but short, and it works in a WPCode snippet too.
Rank Math (filter reference):
add_filter('rank_math/opengraph/facebook/image', function ($image) {
return 'https://shareglint.com/u/acc_….png?url=' . rawurlencode(wp_get_canonical_url() ?: home_url('/'));
});
Yoast SEO has a wpseo_opengraph_image filter, but it only runs when Yoast has already found an image for the page — on a post with no featured image it is never called (Yoast issue #15721). The reliable way is to add the image yourself and let Yoast print it:
add_action('wpseo_add_opengraph_images', function ($images) {
if (is_singular()) {
$images->add_image_by_url('https://shareglint.com/u/acc_….png?url=' . rawurlencode(wp_get_canonical_url()));
}
});
If you prefer images with your own fields — the post title, the author, a category — instead of what the service reads from the page, use a signed image URL with a template such as blog-og; the PHP signing function in the Laravel guide works in WordPress as well — read the account id and signing secret from constants in wp-config.php instead of config().
After you switch: clear the caches that matter
- Your page cache. WP Rocket, LiteSpeed Cache, W3 Total Cache and host-level caches serve the old HTML — and the old
og:image— until they are purged. - The platforms' caches. Paste a post URL into Facebook's Sharing Debugger and click Scrape Again; use LinkedIn's Post Inspector for LinkedIn. Facebook keys its cache on the image URL too, so a changed image under the same file name may still show the old picture (Meta recommends a new URL for a new image).
- Security plugins and firewalls. Some block unknown bots. If previews stay empty, make sure
facebookexternalhit,LinkedInBot,TwitterbotandSlackbotcan fetch both the page and the image.
Which option to pick
| Your situation | Pick |
|---|---|
| A few posts, someone happy to design each image | Option 1: featured images + default |
| Already using Jetpack, its layouts are fine | Option 2: Jetpack Social |
| Many pages, no developer, want it hands-off | Option 3: one snippet via WPCode |
| Happy with Yoast/Rank Math, only the image is missing | Option 4: their filter |
Whichever you choose, check one post on Facebook and LinkedIn before you call it done — the debugging guide covers what to do when the preview still does not appear.