WordPress Open Graph Images from Post Titles

Published October 15, 2026 by Balaji

Uncategorized

WordPress Open Graph images usually mean a featured image someone remembered to upload. The jsontoimg plugin replaces that step: it mints a signed image URL from the post title, so every post gets a share card without a design-tool export. This guide covers the three entry points and the one trap that breaks previews.

Install

Download jsontoimg.zip from the plugin releases, upload it under Plugins, and activate it. It needs WordPress 6.6 and PHP 7.4. Paste an API key under Settings, then jsontoimg, and run Test connection. The key stays in the options table and never appears in frontend HTML.

Option 1: the Gutenberg block

Add the jsontoimg block, pick a template, and fill the layer fields. The preview uses the signed URL. Set as Featured Image downloads the render into the Media Library and assigns it as the post thumbnail, which gives themes and SEO plugins a normal featured_media to read. The post type must support featured images; WordPress documents the underlying call as set_post_thumbnail.

Option 2: the shortcode

layers is JSON and template is its own attribute. WordPress explains how these are registered in add_shortcode.

Option 3: a wp_head tag for every post

To set og:image for all posts, hook wp_head:

add_action( 'wp_head', function () {
  if ( ! is_singular( 'post' ) ) { return; }

  $url = jsontoimg_sign_url( 'DESIGN_ID', [
    'format' => 'png',
    'layers' => [ 'headline' => [ 'text' => get_the_title() ] ],
  ] );
  if ( is_wp_error( $url ) ) { return; }

  printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $url ) );
  printf( '<meta property="og:image:alt" content="%s" />' . "\n", esc_attr( get_the_title() ) );
} );

jsontoimg_sign_url returns a URL string or a WP_Error, and the plugin caches minted URLs in transients, so a page view does not mint or bill again.

The duplicate-tag trap

Many SEO plugins already print an og:image. The Open Graph protocol says that when a tag repeats, the first one from top to bottom wins. Your snippet loses if the plugin’s tag prints earlier. Either turn off the plugin’s image output, or hook wp_head with an earlier priority.

Logo and photo layers

An image_url layer must be a public https file ending in .png, .jpg, .jpeg, or .webp, or a path from the jsontoimg Assets library. A placeholder CDN URL with no file extension fails at render time. Use a file from the Media Library.

Cost

Minting is free. The first unique fetch of each URL bills one credit, and later fetches are cache hits. A post whose title never changes costs one credit total. The wider picture is in the Open Graph image generator guide, and WordPress internals are in the block editor handbook.

FAQ

How do I add Open Graph images to WordPress posts automatically?

Install the jsontoimg plugin, then print an og:image tag in wp_head from jsontoimg_sign_url using the post title. Every post gets a unique card with no manual export.

Why does my WordPress post show the wrong share image?

Usually two og:image tags are printed. The Open Graph protocol gives the first tag priority, so an SEO plugin’s tag can override yours. Disable one of them.

Does the WordPress plugin expose my API key?

No. The key is stored in the options table and used server-side to mint the signed URL. Only the signed URL appears in the HTML.

Can I set the featured image from the render?

Yes. The block has a Set as Featured Image button that downloads the render into the Media Library and assigns it to the post.

Related Resources