How to Set Up OG Images in WordPress
Published June 23, 2026 · 4 min read
WordPress powers over 40% of the web, but it doesn't generate OG images out of the box. Here's how to add them — with plugins and manually.
Option 1: Use an SEO Plugin (Easiest)
Yoast SEO
Go to Yoast SEO → Settings → Social → Facebook. Enable Open Graph metadata. Then on each post, scroll to the Yoast metabox → Social tab → upload your OG image.
Rank Math
Rank Math → Titles & Meta → Open Graph. Enable and configure. On each post, the Rank Math sidebar lets you set a custom OG image.
All in One SEO (AIOSEO)
AIOSEO → Social Networks → Facebook. Toggle on and set a default OG image as fallback. Override per post in the AIOSEO settings panel.
Option 2: Generate with Our Tool
For complete design control, create your OG images with our free generator, then set them as the Featured Image in WordPress. Most SEO plugins use the Featured Image as the og:image automatically.
Option 3: Theme Functions (Manual)
Add this to your theme's functions.php:
function add_og_tags() {
if (is_single()) {
$img = get_the_post_thumbnail_url(null, 'full');
echo '<meta property="og:image" content="' . $img . '">';
echo '<meta property="og:image:width" content="1200">';
echo '<meta property="og:image:height" content="630">';
}
}
add_action('wp_head', 'add_og_tags');
Troubleshooting
- Duplicate tags: Disable OG output in all but one plugin.
- Image not updating: Clear your WordPress cache, then use our OG checker to verify.
- Facebook shows old image: Run the URL through Facebook Sharing Debugger to clear its cache.
Need an OG image for your WordPress post?
Create a professional 1200x630 card in seconds. Free, no signup.
Open Generator →