AI Post Content Generator - DEV
Generate post content using AI with support for custom fields, featured images, and bulk queue processing.
by Nic Scott · github.com/nicscott01/post-content-generator · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/nicscott01/post-content-generator/archive/refs/heads/main.zipAI Post Content Generator
A powerful WordPress plugin that uses AI to generate post content, custom fields, and featured images with support for bulk queue processing.
Features
- 🤖 AI-Powered Content Generation - Generate titles, content, excerpts, and featured images using AI
- 📝 Custom Fields Support - Universal support for ACF, Meta Box, CMB2, and native custom fields
- ⚡ Queue System - Bulk generate content with Action Scheduler integration
- 🎨 Per Post Type Configuration - Customize prompts and settings for each post type
- 🔄 Three Generation Modes:
- Create: Generate entirely new posts
- Overwrite: Replace existing content completely
- Modify: Enhance/improve existing content
- 🎯 Priority-Based Processing - Control the order of content generation
- 📊 Queue Management UI - Monitor and manage generation queue with real-time stats
- 🔧 Template Variables - Dynamic prompt templates with customizable variables
- 🖼️ Image Generation - AI-generated featured images and custom field images
Requirements
- WordPress 6.0 or higher
- PHP 7.4 or higher
- Composer (for dependency management)
- WordPress AI Client configured with API credentials
Installation
-
Clone or download this plugin to your WordPress plugins directory:
cd wp-content/plugins/ git clone [repository-url] post-content-generator -
Install dependencies via Composer:
cd post-content-generator composer install -
Activate the plugin through the WordPress admin panel
-
Configure your AI credentials:
- Go to Settings > AI Credentials
- Enter your API keys for your preferred AI provider (Anthropic, Google, OpenAI, etc.)
Configuration
Global Settings
Navigate to Settings > AI Content Generator to configure:
- Default Temperature: Controls AI randomness (0-2)
- Queue Batch Size: Number of items to process per batch (1-50)
- Enable Logging: Log generation errors to debug.log
Post Type Settings
Each post type has its own configuration tab with:
- Enable/Disable AI generation for the post type
- Global Prompt/Voice: Set overall tone and style
- Temperature Override: Per-post-type temperature setting
- Default Post Status: Draft, Pending, or Published
- Content Generation Options:
- Generate Title (with custom prompt)
- Generate Content (with custom prompt)
- Generate Excerpt (with custom prompt)
- Generate Featured Image (with custom prompt)
- Custom Fields Mapping: Configure AI generation for detected custom fields
Template Variables
Use these variables in your prompts:
{post_type}- The post type name{post_title}- The post title{existing_content}- Current content (for modify mode){field_label}- Custom field label{field_description}- Custom field description{field_value}- Current field value (for modify mode){site_name}- Site name{site_url}- Site URL{date}- Current date
Usage
Adding Items to Queue
- Go to Tools > Content Generator
- Fill out the "Add to Queue" form:
- Select post type
- Choose action (Create/Overwrite/Modify)
- Set priority (lower = higher priority)
- Choose post status
- Set count (for bulk operations)
- Click "Add to Queue"
Managing the Queue
The queue page provides:
- Real-time Statistics: View pending, processing, completed, and failed items
- Filters: Filter by status and post type
- Bulk Actions: Delete or retry multiple items
- Individual Actions: Process, retry, or delete single items
Queue Processing
The queue is automatically processed every 5 minutes via Action Scheduler. Processing includes:
- Fetch pending items based on priority
- Generate content according to post type settings
- Create/update posts with generated content
- Update queue item status
- Log any errors
Custom Field Support
The plugin automatically detects custom fields from:
- Advanced Custom Fields (ACF)
- Meta Box
- CMB2
- Native WordPress custom fields
For each detected field, you can:
- Enable/disable AI generation
- Set a custom prompt
- Use field metadata as context
Image Fields
Image-type custom fields are automatically handled:
- AI generates the image
- Image is uploaded to WordPress media library
- Attachment ID is saved to the custom field
Development
File Structure
post-content-generator/
├── post-content-generator.php (Main plugin file)
├── composer.json
├── includes/
│ ├── class-plugin.php (Core plugin class)
│ ├── class-settings.php (Settings management)
│ ├── class-queue.php (Queue system)
│ ├── class-content-generator.php (AI text generation)
│ ├── class-meta-field-handler.php (Custom fields)
│ └── class-image-generator.php (AI image generation)
├── admin/
│ ├── class-settings-page.php (Settings UI)
│ ├── class-queue-page.php (Queue UI)
│ └── assets/
│ ├── css/admin.css
│ └── js/admin.js
└── vendor/ (Composer dependencies)
Hooks and Filters
Actions:
pcg_process_queue- Triggered for queue processingpcg_before_generate_content- Before content generationpcg_after_generate_content- After content generation
Filters:
pcg_custom_fields- Modify detected custom fieldspcg_prompt_variables- Add custom template variablespcg_queue_batch_size- Override batch sizepcg_default_temperature- Override default temperature
Extending the Plugin
You can extend functionality by:
- Adding custom field frameworks via
pcg_custom_fieldsfilter - Adding custom template variables via
pcg_prompt_variablesfilter - Hooking into generation lifecycle with actions
- Creating custom queue processors
Troubleshooting
AI Generation Not Working
- Check AI credentials in Settings > AI Credentials
- Verify post type has AI generation enabled
- Check debug.log for errors (if logging is enabled)
- Ensure prompts are properly configured
Queue Not Processing
- Verify Action Scheduler is working (check scheduled actions)
- Check if WP Cron is enabled
- Review error messages in queue items
- Check server PHP error logs
Custom Fields Not Detected
- Ensure custom field plugin (ACF, Meta Box, etc.) is active
- Verify field groups are assigned to the post type
- Check if fields are visible in post editor
Support
For issues and feature requests, please use the GitHub issue tracker.
License
This plugin is licensed under the GPL v2 or later.
Credits
Built with:
Version: 1.0.0
Author: Nick Scott
Requires WordPress: 6.0+
Requires PHP: 7.4+