{"id":310,"date":"2026-10-15T21:33:07","date_gmt":"2026-10-15T21:33:07","guid":{"rendered":"https:\/\/blog.skndan.com\/jsontoimg\/2026\/10\/15\/wordpress-open-graph-images-from-post-titles\/"},"modified":"2026-11-17T13:33:23","modified_gmt":"2026-11-17T13:33:23","slug":"wordpress-open-graph-images-from-post-titles","status":"publish","type":"post","link":"https:\/\/blog.skndan.com\/jsontoimg\/2026\/10\/15\/wordpress-open-graph-images-from-post-titles\/","title":{"rendered":"WordPress OG Image Automation from Post Titles"},"content":{"rendered":"<p>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 to WordPress OG image automation covers the three entry points and the one trap that breaks previews.<\/p>\n<h2>Install<\/h2>\n<p>Download <code>jsontoimg.zip<\/code> from the <a href=\"https:\/\/github.com\/jsontoimg\/wordpress\/releases\/download\/1.0.0\/jsontoimg.zip\">plugin releases<\/a>, 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.<\/p>\n<h2>Option 1: the Gutenberg block<\/h2>\n<p>Add the jsontoimg block, pick a template, and fill the layer fields. The preview uses the signed URL. <strong>Set as Featured Image<\/strong> downloads the render into the Media Library and assigns it as the post thumbnail, which gives themes and SEO plugins a normal <code>featured_media<\/code> to read. The post type must support featured images; WordPress documents the underlying call as <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/set_post_thumbnail\/\"><code>set_post_thumbnail<\/code><\/a>.<\/p>\n<h2>Option 2: the shortcode<\/h2>\n<pre><code>\n<\/code><\/pre>\n<p><code>layers<\/code> is JSON and <code>template<\/code> is its own attribute. WordPress explains how these are registered in <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/add_shortcode\/\"><code>add_shortcode<\/code><\/a>.<\/p>\n<h2>Option 3: a <code>wp_head<\/code> tag for every post<\/h2>\n<p>To set <code>og:image<\/code> for all posts, hook <a href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/wp_head\/\"><code>wp_head<\/code><\/a>:<\/p>\n<pre><code>add_action( &#39;wp_head&#39;, function () {\n  if ( ! is_singular( &#39;post&#39; ) ) { return; }\n\n  $url = jsontoimg_sign_url( &#39;DESIGN_ID&#39;, [\n    &#39;format&#39; =&gt; &#39;png&#39;,\n    &#39;layers&#39; =&gt; [ &#39;headline&#39; =&gt; [ &#39;text&#39; =&gt; get_the_title() ] ],\n  ] );\n  if ( is_wp_error( $url ) ) { return; }\n\n  printf( &#39;&lt;meta property=&quot;og:image&quot; content=&quot;%s&quot; \/&gt;&#39; . &quot;\\n&quot;, esc_url( $url ) );\n  printf( &#39;&lt;meta property=&quot;og:image:alt&quot; content=&quot;%s&quot; \/&gt;&#39; . &quot;\\n&quot;, esc_attr( get_the_title() ) );\n} );\n<\/code><\/pre>\n<p><code>jsontoimg_sign_url<\/code> returns a URL string or a <code>WP_Error<\/code>, and the plugin caches minted URLs in transients, so a page view does not mint or bill again.<\/p>\n<h2>The duplicate-tag trap<\/h2>\n<p>Many SEO plugins already print an <code>og:image<\/code>. The <a href=\"https:\/\/ogp.me\/\">Open Graph protocol<\/a> says that when a tag repeats, the first one from top to bottom wins. Your snippet loses if the plugin&#39;s tag prints earlier. Either turn off the plugin&#39;s image output, or hook <code>wp_head<\/code> with an earlier priority.<\/p>\n<h2>Logo and photo layers<\/h2>\n<p>An <code>image_url<\/code> layer must be a public <code>https<\/code> file ending in <code>.png<\/code>, <code>.jpg<\/code>, <code>.jpeg<\/code>, or <code>.webp<\/code>, 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.<\/p>\n<h2>Cost<\/h2>\n<p>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 <a href=\"https:\/\/jsontoimg.com\/blog\/open-graph-image-generator-guide\">Open Graph image generator guide<\/a>, and WordPress internals are in the <a href=\"https:\/\/developer.wordpress.org\/block-editor\/\">block editor handbook<\/a>.<\/p>\n<h2>FAQ<\/h2>\n<h3>How do I add Open Graph images to WordPress posts automatically?<\/h3>\n<p>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.<\/p>\n<h3>Why does my WordPress post show the wrong share image?<\/h3>\n<p>Usually two og:image tags are printed. The Open Graph protocol gives the first tag priority, so an SEO plugin&#39;s tag can override yours. Disable one of them.<\/p>\n<h3>Does the WordPress plugin expose my API key?<\/h3>\n<p>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.<\/p>\n<h3>Can I set the featured image from the render?<\/h3>\n<p>Yes. The block has a Set as Featured Image button that downloads the render into the Media Library and assigns it to the post.<\/p>\n<h2>Related Resources<\/h2>\n<ul>\n<li><a href=\"https:\/\/jsontoimg.com\/use-cases\/open-graph-images\">OG image API<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/og-image-not-showing-debug-checklist\">OG image not showing? Debug checklist<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/integrations\">Image generation integrations<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/json-to-image-converter\">How JSON-to-image conversion works<\/a> \u2014 the pillar guide<\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/open-graph-image-generator-guide\">Open Graph image generator guide<\/a> \u2014 the full flow<\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/docs\/integrations\/wordpress\">WordPress plugin docs<\/a> \u2014 install and helpers<\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/auto-generate-og-images-with-jsontoimg\">Sign Open Graph image URLs in Next.js and WordPress<\/a> \u2014 the earlier walkthrough<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Generate WordPress Open Graph images from post titles with the jsontoimg plugin: the block, the shortcode, a wp_head snippet, and the duplicate-tag trap.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-310","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/comments?post=310"}],"version-history":[{"count":1,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/310\/revisions"}],"predecessor-version":[{"id":369,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/310\/revisions\/369"}],"wp:attachment":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/media?parent=310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/categories?post=310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/tags?post=310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}