Open Graph
Adding Open Graph tags in WordPress
Quick answer
Open Graph tags tell networks what title, description and image to show when your page is shared. In WordPress, let one SEO plugin output them, set a default image, and override the title, description and image per post where needed. Check the page source for duplicates from your theme or a share plugin, then test in each network's debugger.
On this page
The tags that matter
| Tag | Required by the protocol | What it controls |
|---|---|---|
| og:title | Yes | Headline on the preview card |
| og:type | Yes | Usually website or article |
| og:image | Yes | The preview image |
| og:url | Yes | The canonical address the share counts against |
| og:description | No | One or two lines under the title |
| og:site_name | No | Your site name on some cards |
| og:image:width and og:image:height | No | Lets the network lay out the card before downloading the image |
Option 1: one SEO plugin
Pick one source
Most SEO plugins output Open Graph tags. Use exactly one plugin for them; turn off the same feature in your share plugin and theme.
Set defaults
Add a default share image, 1200 by 630 pixels, for pages without their own. See Open Graph image size.
Override per post
In the post editor's social settings, write a share title and description when the SEO title does not suit a social feed.
Check the source
View the page source and search for
og:image. There should be one set of tags.Test
Run the address through the Sharing Debugger and the LinkedIn Post Inspector.
Option 2: theme code
If you do not use an SEO plugin, print the tags from wp_head in your child theme. Use the post's featured image at a registered size of 1200 by 630, fall back to a site default, and escape every value.
add_action( 'wp_head', function () {
if ( ! is_singular() ) { return; }
$img = get_the_post_thumbnail_url( null, 'og-image' ) ?: 'https://example.com/default-share.png';
printf( '<meta property="og:title" content="%s">', esc_attr( get_the_title() ) );
printf( '<meta property="og:type" content="article">' );
printf( '<meta property="og:url" content="%s">', esc_url( get_permalink() ) );
printf( '<meta property="og:image" content="%s">', esc_url( $img ) );
} );Why share plugins shipped their own tags
Some share plugins, MashShare with its Open Graph add-on among them, generated tags so that the image chosen for sharing matched the buttons. That made sense when few themes printed tags. Today it usually means two conflicting sets, which is the most common cause of the wrong image appearing on Facebook.
Questions
Do I need a plugin for Open Graph tags?
No, but an SEO plugin is the easiest way. Theme code in wp_head works if you escape every value.
Which Open Graph tags are required?
The protocol requires og:title, og:type, og:image and og:url. Description and image dimensions are strongly recommended.
Why do I have two sets of Open Graph tags?
Your theme, SEO plugin or share plugin each output tags. Turn the feature off in all but one.
Hannah Voss, Editor. Checks every guide against a working WordPress install and the networks' current documentation. Last reviewed September 2026.
Related guides
- Facebook showing the wrong image or share textFix Facebook showing the wrong image or text when you share a WordPress post: duplicate tags, small images, cache, blocked crawlers, and the Sharing Debugger.3 min read
- Open Graph image size: 1200 by 630 and the safe zoneThe right Open Graph image size is 1200 by 630 pixels at a 1.91:1 ratio. Minimums, file limits, formats, and a centre safe zone for square crops.3 min read
- Twitter cards on X: tags and testingSet up Twitter card tags so links to your WordPress posts show a large image on X: the summary_large_image card, fallbacks to Open Graph, sizes and testing.3 min read