WP Manifestindependent plugin directory
manifest / ai / post-content-generator

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

0stars
0forks

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.zip

AI 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

  1. Clone or download this plugin to your WordPress plugins directory:

    cd wp-content/plugins/
    git clone [repository-url] post-content-generator
  2. Install dependencies via Composer:

    cd post-content-generator
    composer install
  3. Activate the plugin through the WordPress admin panel

  4. 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

  1. Go to Tools > Content Generator
  2. 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)
  3. 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:

  1. Fetch pending items based on priority
  2. Generate content according to post type settings
  3. Create/update posts with generated content
  4. Update queue item status
  5. 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 processing
  • pcg_before_generate_content - Before content generation
  • pcg_after_generate_content - After content generation

Filters:

  • pcg_custom_fields - Modify detected custom fields
  • pcg_prompt_variables - Add custom template variables
  • pcg_queue_batch_size - Override batch size
  • pcg_default_temperature - Override default temperature

Extending the Plugin

You can extend functionality by:

  1. Adding custom field frameworks via pcg_custom_fields filter
  2. Adding custom template variables via pcg_prompt_variables filter
  3. Hooking into generation lifecycle with actions
  4. Creating custom queue processors

Troubleshooting

AI Generation Not Working

  1. Check AI credentials in Settings > AI Credentials
  2. Verify post type has AI generation enabled
  3. Check debug.log for errors (if logging is enabled)
  4. Ensure prompts are properly configured

Queue Not Processing

  1. Verify Action Scheduler is working (check scheduled actions)
  2. Check if WP Cron is enabled
  3. Review error messages in queue items
  4. Check server PHP error logs

Custom Fields Not Detected

  1. Ensure custom field plugin (ACF, Meta Box, etc.) is active
  2. Verify field groups are assigned to the post type
  3. 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+