WP-CLI and REST for Programmatic SEO
4 min read
Programmatic SEO has no commands of its own. Its tasks are ordinary background tasks, so the general task commands apply. Everything else (creating tasks, converting pages, AI settings) is done in the admin or through the REST API.
Task commands
wp wpmcf tasks list
wp wpmcf tasks run <id>wp wpmcf tasks list prints a table with the columns id, name, type, status, next_run and attempts for every task of the plugin. Page generation shows up as:
|
| What it is |
|---|---|---|
| The task's name, for example "City pages" | The page generation task |
|
| The AI run of that task (created when you first start AI) |
|
| The post conversion of that task |
| Data table import and feed sync | Not Programmatic SEO, but they feed it (Data sources) |
wp wpmcf tasks run <id> runs an active task in the foreground, batch after batch, until its current run is over, then prints "Ran N batch(es). Status: …". It refuses tasks that are not active: "Task 12 is paused; activate it first." (also for completed ones). A page generation task is active while it runs or waits for its schedule; to start a paused or finished task click Run now (or call the REST route below), then use the command to execute it in your shell instead of waiting for WP-Cron.
Typical uses:
- on a server without WP-Cron traffic, run the whole queue from a system cron job, see Background tasks:
* * * * * cd /var/www/site && wp action-scheduler run --group=wpmcf --batches=1 >/dev/null 2>&1- after a big import, trigger the run you need and run it directly:
wp wpmcf tasks list
wp wpmcf tasks run 12The command does all the work in one PHP process: give it enough memory (php -d memory_limit=1G $(which wp) …) for large runs. More about the commands: WP-CLI commands.
REST routes
All routes live under /wp-json/wpmcf/v1/, need an administrator (manage_options), a nonce or an application password, and the Pro feature that belongs to the route (Programmatic SEO, AI or post conversion). Without the plan they answer HTTP 403 "Your current plan does not include this feature."
Method and route | Purpose |
|---|---|
| List and create tasks. |
| Read, update (the same body as create; |
| The preview of a task configuration without saving (first pages, total) |
| Start or pause a task |
| Deletes all pages of the task and resets its progress (not available in the admin UI) |
| The last runs of the task |
| Pages with |
| Hide or show a page |
| Bulk actions: |
| The SEO health checks |
| The page editor data; |
| Set by hand or reset one value ( |
| Update the source row of a page |
| Sources with columns, usable post types and templates |
| The structured data catalog and a preview |
| The multilingual plugin and its languages |
| The quick start state, create the sample, delete it and generate its first pages |
| Conversion overview, pre-flight and start ( |
| AI state with estimate, start a run |
| Queue one page for an AI rewrite |
| The Settings › AI screen. The key is write-only. |
Example: create a task and start it, from a script with an application password:
curl -u admin:"abcd efgh ijkl mnop" -X POST https://example.com/wp-json/wpmcf/v1/pseo/tasks \
-H 'Content-Type: application/json' \
-d '{
"name": "City pages",
"post_type": "page",
"template_id": 42,
"generation": {
"mode": "row",
"sources": [{"type": "src", "key": "cities", "filters": []}],
"path": {"parent": "guides", "slug": "{{ pseo.src.cities.name }}"},
"title": "Best hotels in {{ pseo.src.cities.name }}"
},
"run": true
}'Validation errors answer HTTP 422 with the message the editor shows ("Choose a page template.", "Enter a URL pattern for the page slug."), plan limits HTTP 403.
Still stuck? Contact support