Skip to content
Ruhani RabinRuhani Rabin

Auto Featured Image by Post Types Using Robolly API and Templates

WPCodeBox
This snippet uses Robolly Templates and API to generate Featured Images for a Specific Post Type. It has WP Admin page inside Settings > AFI—Robolly. A screenshot of the AFI Robolly Settings page in WordPress displays places where you can enter the Robolly API key and template IDs to automatically create featured images. There are settings for various post types and links to more information about Robolly and donations.

Conditions:

  1. Requires Robolly Template to be done
  2. Requires Robolly API key
  3. A post with a published status, only if there is NO featured image already attached
  4. Setup credentials in Settings > AFI — Robolly

Operation:

  1. Set up a Template in Robolly
  2. Copy the Template ID and Robolly API Key
  3. Set up the preferences
  4. Now go to a published post or page
  5. Make sure there are no existing-featured images is set to the post
  6. Press Save — wait for it to work
  7. Refresh the post editor to see the new featured image

Works with:

  1. WP CodeBox
  2. FluentSnippets
  3. Other Code Snippets Plugins

Additional Snippets

CHANGELOG: Version 1.2 (2026-01-15) - Added support for extracting first image from post content (per post-type control) - Added minimum image width validation (600px default, configurable per post-type) - Added image parameter name configuration for Robolly templates (per post-type) - Added automatic image dimension detection - Added support for sending images to Robolly API via URL parameter - Enhanced error logging for image extraction process - Added fallback behavior when no suitable image is found - Added version management and automatic settings migration - Per post-type configuration for image extraction feature - Added manual save/update support with duplicate prevention - Plugin now works on save/update events, not just publish - Smart tracking prevents multiple generations for same post - Auto-reset generation flag when featured image is manually deleted - Allow regeneration by simply deleting featured image and saving again Version 1.1 - Added image metadata generation settings - Added support for custom post types - Improved error handling and retry logic Version 1.0 - Initial release   Copy the code and paste it inside your favorite code-snippet plugin.
View on GitHub

Screenshots

Share: