OG Pilot
WordPress guide

How to add OG Pilot social images to WordPress

Give every WordPress post a scroll-stopping Open Graph preview. This guide shows how to connect OG Pilot to your theme so each share pulls the right branded image automatically.

What you need

Before you start

  • An active OG Pilot subscription to generate and host your image variations.
  • Administrator access to the WordPress site you want to update.
  • Your domain configured in OG Pilot to generate social images automatically.
  • A recent backup of functions.php in case you need to undo changes quickly.

Time to complete

About 5 minutes

The update applies instantly once the file is saved. Some social platforms may cache the previous image until you force a re-scrape.

WordPress integration steps

Follow this proven workflow to insert custom Open Graph and Twitter Card meta tags powered by OG Pilot directly into your theme.

1

Open the Theme Editor

Log in to your WordPress admin dashboard, navigate to Appearance, and choose Theme File Editor. Open functions.php from the theme on your live site.

2

Paste the OG Pilot helper

Scroll to the bottom of functions.php and paste the OG Pilot function before the closing PHP tag. The helper automatically pulls in the current permalink and passes it to OG Pilot to generate the social image.

3

Save and verify the tags

Click Update File, view the page source, and confirm the new og:image and twitter:image tags appear on single posts and pages.

4

Test with sharing validators

Use the Facebook Sharing Debugger and X (Twitter) Card Validator to trigger a fresh scrape so platforms pick up your new OG Pilot image immediately.

You are done! Future OG Pilot images will populate automatically whenever a post or page is shared.

Copy & paste helper

Drop this snippet into functions.php

This helper calls get_permalink() to get the current page URL and passes it through the url query parameter to OG Pilot, which automatically generates a branded social image for every post and page.

function add_custom_og_tags() {
    if (is_single() || is_page()) {
        $page_url = get_permalink();
        $og_image_url = add_query_arg(
            ['url' => $page_url],
            'https://ogpilot.com/image/get'
        );
        $escaped_og_image_url = esc_url($og_image_url);
        echo '<meta property="og:image" content="' . $escaped_og_image_url . '" />' . "\n";
        echo '<meta property="og:image:width" content="1200" />' . "\n";
        echo '<meta property="og:image:height" content="630" />' . "\n";
        echo '<meta property="og:image:type" content="image/png" />' . "\n";
        echo '<meta name="twitter:card" content="summary_large_image" />' . "\n";
        echo '<meta name="twitter:image" content="' . $escaped_og_image_url . '" />' . "\n";
    }
}
add_action('wp_head', 'add_custom_og_tags');

Keep your WordPress previews on-brand

Create unlimited variations with OG Pilot so your headlines, product shots, and campaigns always look fresh across Facebook, LinkedIn, X, and more.

Generate new images

Pro tip

OG Pilot will automatically use your configured domain settings and templates to generate a polished preview for every page, ensuring consistent branding across all your WordPress content.