WP-CLI commands

The five WP-CLI commands Aimogen Pro registers for generating content, editing posts and running rules from the command line.

Aimogen Pro registers WP-CLI commands for content generation, bulk editing and running rules — useful for scripting, scheduling outside WP-Cron, and processing large batches without a browser.

WP-CLI Integration - Write AI Content Using WP Command Line InterfaceUsing the CLI commands.Watch on YouTube

This tutorial was recorded before Aiomatic was renamed to Aimogen Pro. Some labels or interface elements may differ slightly from the current version.

WP-CLI Integration in Aimogen: Automate AI Content Editing & Bulk Post CreationEditing and bulk creation from the CLI.Watch on YouTube

This tutorial was recorded before Aiomatic was renamed to Aimogen Pro. Some labels or interface elements may differ slightly from the current version.

Enabling#

Settings › WP-CLI › Enable WP-CLI must be on. Without it the commands are not registered.

An API key must also be configured; every command errors out with You need to add an AI API key in the Aimogen plugin settings for this to work! otherwise.

The commands#

CommandAliasPurpose
wp aicontentGenerate text from a prompt
wp aimogen-editwp aiomatic-editRun the AI Content Editor over posts
wp aimogen-runwp aiomatic-runRun a bulk rule or workflow
wp aimogen-agentRun an AI Agent

Both aimogen- and aiomatic- spellings are registered for the edit and run commands.

wp aicontent <model> <prompt>#

bash
wp aicontent gpt-5-mini "Write a two-sentence summary of WP-CLI"

Prints the generated text. Errors on an empty prompt or an empty response.

wp aimogen-edit <post_id_list> [<editing_template_ID>]#

bash
# One post, default template
wp aimogen-edit 42

# Several posts, a specific editor template
wp aimogen-edit 42,43,44,45 7
ParameterRequiredMeaning
post_id_listyesComma-separated post IDs
editing_template_IDnoAn editor template ID. Omitted means default handling

Limit: 1000 post IDs per invocation. More errors with Too many posts.

The command flushes the object cache and runs garbage collection every ten posts, which is what makes large batches survivable.

wp aimogen-run <rule_type> <rule_id>#

bash
# Rule 3 of the keyword creator
wp aimogen-run 0 3

# Several OmniBlock workflows
wp aimogen-run 5 1,2,7
Rule typeCreator
0Keywords/Titles to blog posts
1YouTube videos to posts
2AI product roundup
3AI product reviews
4CSV AI post creator
5OmniBlocks
6Listicles
7Forum topics
8Topic replies

Rule IDs may be comma-separated.

wp aimogen-agent <agent_id> [--task=<task>] [--verbose]#

bash
# Run agent 42 with its stored task
wp aimogen-agent 42

# Run it with a specific task, showing the result
wp aimogen-agent 42 --task="Find posts published this month with no featured image and report their IDs" --verbose
ParameterRequiredMeaning
agent_idyesThe agent post ID
--tasknoA task for this run. Without it, the agent stored task is used
--verbosenoPrint the result as well as the timing

The command clears the agent working memory and current task before starting, sets its status to running, and executes synchronously — unlike the admin path, which dispatches one step per cron event.

It reports the elapsed time on success, and errors with the exception message if the agent crashes.

Why the CLI is worth using#

No PHP timeout. CLI execution is not bounded by web server limits, so large batches complete.

Real scheduling. Drive generation from system cron rather than WP-Cron:

bash
# Every night at 02:00, run keyword rule 3
0 2 * * * cd /var/www/example.com && wp aimogen-run 0 3 >> /var/log/aimogen.log 2>&1

Bulk editing at scale. Editing a thousand posts through the admin means many browser batches. From the CLI it is one command.

bash
# Edit every post in category 5 with template 7
wp post list --category=5 --format=ids --posts_per_page=-1 \
  | tr ' ' ',' \
  | xargs -I {} wp aimogen-edit {} 7

Deterministic ordering. The CLI processes in the order you supply.

Practical guidance#

Redirect output to a log. Errors are the thing you will want afterwards.

Watch memory. The edit command cleans up periodically, but very large batches on a small server still need --skip-plugins for unrelated plugins, or a raised memory limit.

Costs are real. A CLI command bypasses no limits — it makes the same paid API calls. Check System & Logs › Usage Logs afterwards.

Multisite. Use --url= to target a specific site.

bash
wp aimogen-run 0 3 --url=https://sub.example.com

Common problems#

wp aicontent is not a registered command. WP-CLI is enabled in settings but the plugin is not loading — check that you are running wp from the WordPress root, and that the plugin is active.

You need to add an AI API key. No key configured, or you are targeting the wrong site on multisite.

Too many posts. More than 1000 IDs. Split the batch.

Parameters missing. The command prints its usage. Note that aimogen-run requires rule type and rule ID, in that order.

The command hangs. A slow model, or a rule making many requests. It is working; watch Live AI Activity in another window.

Still stuck? Open a support ticket and include the diagnostics from Aimogen Pro › System & Logs › System Info.