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.
The update applies instantly once the file is saved. Some social platforms may cache the previous image until you force a re-scrape.
Follow this proven workflow to insert custom Open Graph and Twitter Card meta tags powered by OG Pilot directly into your theme.
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.
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.
Click Update File, view the page source, and confirm the new og:image and twitter:image tags appear on single posts and pages.
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.
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');
Create unlimited variations with OG Pilot so your headlines, product shots, and campaigns always look fresh across Facebook, LinkedIn, X, and more.
Generate new imagesPro 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.