Skip to content
Shareglow

Open Graph fixes · WordPress

Fix missing Open Graph tags in WordPress

In WordPress the Open Graph tags live in functions.php, which prints the meta tags from a wp_head action. Below is the complete snippet plus the one-tag fix for each of the 10 core tags our scanner checks, so you can patch exactly what the scan flagged.

The fix

Add this to functions.php

// functions.php
add_action('wp_head', function () {
  echo '<meta property="og:title" content="Your page title">';
  echo '<meta property="og:description" content="A one or two sentence summary of this page.">';
  echo '<meta property="og:image" content="https://example.com/og.png">';
  echo '<meta property="og:url" content="https://example.com/page">';
  echo '<meta name="twitter:card" content="summary_large_image">';
});

Heads up: The snippet is a static example: swap the sample values for per-page ones such as get_the_title(), get_permalink() and get_the_post_thumbnail_url(). Remove any existing OG tags first, because themes and SEO plugins often print them already. Edit a child theme's functions.php so theme updates don't erase the change.

  1. Open functions.php in your WordPress project.
  2. Paste the snippet and replace the sample title, description, image and URL with your own.
  3. Deploy, then scan the live URL: the scanner re-checks all 10 tags and lists what is still missing.

One tag at a time

Fix a single missing tag in WordPress

title

// functions.php
add_action('wp_head', function () {
  echo '<title>Your page title</title>';
});

meta description

// functions.php
add_action('wp_head', function () {
  echo '<meta name="description" content="A one or two sentence summary of this page.">';
});

og:title

// functions.php
add_action('wp_head', function () {
  echo '<meta property="og:title" content="Your page title">';
});

og:description

// functions.php
add_action('wp_head', function () {
  echo '<meta property="og:description" content="A one or two sentence summary of this page.">';
});

og:image

// functions.php
add_action('wp_head', function () {
  echo '<meta property="og:image" content="https://example.com/og.png">';
});

og:url

// functions.php
add_action('wp_head', function () {
  echo '<meta property="og:url" content="https://example.com/page">';
});

og:type

// functions.php
add_action('wp_head', function () {
  echo '<meta property="og:type" content="website">';
});

og:site_name

// functions.php
add_action('wp_head', function () {
  echo '<meta property="og:site_name" content="Your site name">';
});

twitter:card

// functions.php
add_action('wp_head', function () {
  echo '<meta name="twitter:card" content="summary_large_image">';
});

twitter:image

// functions.php
add_action('wp_head', function () {
  echo '<meta name="twitter:image" content="https://example.com/og.png">';
});

Check the WordPress fix on a live URL

FAQ

Common questions

Where do Open Graph tags go in WordPress?

In functions.php. The snippet prints the meta tags from a wp_head action.

Which Open Graph tags does WordPress need?

At minimum og:title, og:description, og:image and og:url, plus twitter:card. The scanner checks 10 tags in total: title, meta description, og:title, og:description, og:image, og:url, og:type, og:site_name, twitter:card, twitter:image.

How do I confirm the WordPress fix worked?

Deploy, paste the live URL into the free scanner, and check that every tag above passes. The simulator then draws the card for 30 platforms.

Other frameworks