Skip to content
Gary Jones edited this page Apr 24, 2026 · 1 revision

Co-Authors Plus registers a set of WP-CLI subcommands under the wp co-authors-plus namespace. They exist for three kinds of job:

  • Backfills and migrations — populating missing data after an installation, import or role-remapping.
  • Bulk reassignment — renaming, swapping, merging or retargeting co-authors across many posts in one pass.
  • Creation from external sources — WXR files, CSV files or existing WP users.

This page covers every subcommand in the plugin. For the highest-value command — create-author-terms-for-posts — there's a dedicated deep-dive at Backfilling coauthor terms for legacy posts.

Before you run any of these on a production site, take a database backup. Most of these commands write, several of them in bulk, and none of them have a dry-run mode unless noted. Test on a staging mirror first.

Backfills and term maintenance

create-author-terms-for-posts

Seeds author taxonomy terms from post_author for every post that lacks them. The modern, batch-aware backfill — prefer this over create-terms-for-posts.

wp co-authors-plus create-author-terms-for-posts \
    [--post-types=<csv>] [--post-statuses=<csv>] [--unbatched] \
    [--records-per-batch=<n>] [--specific-post-ids=<csv>] \
    [--above-post-id=<id>] [--below-post-id=<id>]

Batches 250 posts at a time; sleeps one second every 500 posts. Skips any post that already has author terms, and marks posts whose post_author no longer exists so subsequent runs don't retry them.

See the dedicated page for every flag, examples, and performance notes.

create-terms-for-posts

The older, untargeted backfill. Walks the full posts table from the beginning every run and can't be targeted to specific post types, statuses or ID ranges. Still useful for small sites where the extra options aren't worth it; on everything else, prefer create-author-terms-for-posts.

wp co-authors-plus create-terms-for-posts

No arguments. Processes every post type that supports co-authors, 100 posts at a time.

delete-postmeta-that-skip-author-term-backfill

Removes the _cap_skip_backfill post meta that create-author-terms-for-posts sets when it encounters a post whose post_author doesn't exist. Run this if you've since restored or recreated those user accounts and want the backfill to have another go.

wp co-authors-plus delete-postmeta-that-skip-author-term-backfill [--specific-post-ids=<csv>]

With no arguments, clears the meta from every post that has it. Pass --specific-post-ids to target individual posts.

migrate-author-terms

A one-shot compatibility fix from the transition to the cap- term prefix. Adds the prefix to any author terms created before the plugin started namespacing them. Safe to run more than once — already-prefixed terms are left alone.

wp co-authors-plus migrate-author-terms

You only need this on sites that were running extremely old CAP versions (pre-3.0). Modern sites can ignore it.

update-author-terms

Refreshes each author term's cached post count and description to match its source WP user or guest-author profile. Run after bulk user edits, or if term counts appear stale in the admin.

wp co-authors-plus update-author-terms

remove-terms-from-revisions

Historical cleanup: strips author taxonomy terms from post revisions, where they were accidentally being stored for a time. Safe on any site; a no-op if your revisions are already clean.

wp co-authors-plus remove-terms-from-revisions

list-posts-without-terms

Emits CSV-formatted output of posts that are missing author terms, without modifying anything. Useful for auditing before or after a backfill.

wp co-authors-plus list-posts-without-terms [--post_type=<ptype>]

Defaults to post. Pass --post_type=page or similar to target another type.

Bulk reassignment

assign-user-to-coauthor

For a named WP user, reassigns every post they are the post_author on to a co-author. Useful when a user account is leaving the site and you want their bylines to migrate to a guest-author profile.

wp co-authors-plus assign-user-to-coauthor \
    --user_login=<wp-user-login> \
    --coauthor=<co-author-login>

Sleeps two seconds every 100 posts.

assign-coauthors

Reads a post-meta value on each post and uses it to look up a co-author by login. Purpose-built for imports from systems that stash the intended byline in a meta field like _original_import_author.

wp co-authors-plus assign-coauthors \
    [--meta_key=<key>] \
    [--post_type=<ptype>] \
    [--append_coauthors]

Defaults: --meta_key=_original_import_author, --post_type=post. By default the matched co-author replaces the post's existing co-authors; pass --append_coauthors to add alongside them.

swap-coauthors

Replaces one co-author with another on every post they appear on. Supports dry-run.

wp co-authors-plus swap-coauthors \
    --from=<user-login> \
    --to=<user-login> \
    [--post_type=<ptype>] \
    [--dry=<dry>]

Pass any truthy value (e.g. --dry=1) to run without making changes. Batches 100 posts.

rename-coauthor

Renames a single co-author. Updates the author term, the guest-author post's post_name, and the cap-user_login meta in one pass, so the slug used in URLs stays consistent.

wp co-authors-plus rename-coauthor \
    --from=<old-user-login> \
    --to=<new-user-login>

Use this rather than editing the guest-author post title directly — the latter leaves the slug and term out of sync.

reassign-terms

Migrates author terms either one-at-a-time or in bulk via a mapping file. Handy when you're consolidating duplicate co-author profiles or renaming a batch of slugs.

wp co-authors-plus reassign-terms \
    [--author-mapping=<file>] \
    [--old_term=<slug>] \
    [--new_term=<slug>]
  • With --author-mapping=<file>, reads a JSON file mapping old slugs → new slugs and processes every entry.
  • With --old_term and --new_term, performs a single migration.

Creating guest authors in bulk

create-author

Creates a single guest author from the command line. All args are optional and map to the guest-author profile fields.

wp co-authors-plus create-author \
    [--display_name=<name>] \
    [--user_login=<slug>] \
    [--first_name=<name>] [--last_name=<name>] \
    [--website=<url>] \
    [--user_email=<email>] \
    [--description=<bio>]

create-guest-authors

For every existing WordPress user on the site, creates a guest-author profile that maps back to them. Use this immediately after installing CAP on a site with existing user accounts, so every author already has a guest-author profile that content editors can fall back on.

wp co-authors-plus create-guest-authors

Processes 100 users per batch with a progress bar.

create-guest-authors-from-csv

Creates guest-author profiles from a CSV file. Column headers map to guest-author field slugs (display_name, user_login, first_name, last_name, user_email, website, description, etc.).

wp co-authors-plus create-guest-authors-from-csv --file=<path-to-csv>

create-guest-authors-from-wxr

Creates guest-author profiles from a WordPress WXR export file. Extracts every author referenced in the file and creates a matching guest-author profile.

wp co-authors-plus create-guest-authors-from-wxr --file=<path-to-wxr>

Global options

All these subcommands honour the usual WP-CLI global flags:

  • --url=<site-url> to target a specific site on multisite installs.
  • --user=<login> to act as a specific user (a few of the commands care about capability checks).
  • --quiet to suppress progress output; --debug to see internal query logging.

Multisite considerations

  • Author terms and guest-author posts are per-site on multisite. Run any backfill once per site you want to touch — wp site list --field=url | xargs -I{} wp --url={} co-authors-plus create-author-terms-for-posts is a common pattern.
  • create-guest-authors operates against the current site's users only. Network users with no posts on the current site are skipped.

Performance guidance

  • Every command that touches many posts includes a deliberate sleep between batches. Don't patch that out — it protects the database from being hammered.
  • For very large sites, break create-author-terms-for-posts into ID ranges using --above-post-id and --below-post-id, and run the ranges in parallel against a replica-aware database.
  • Redirect output to a file when running under a scheduler: wp … > backfill.log 2>&1. Progress output at scale can exhaust terminal scrollback faster than you'd expect.

Troubleshooting

  • "No author found for user login": the co-author in --from / --coauthor doesn't exist as either a WP user or a guest author on this site. Check the slug with wp post list --post_type=guest-author --format=ids or wp user list.
  • Term counts don't match after a bulk operation: run update-author-terms to refresh.
  • Backfill command returns early: check for the _cap_skip_backfill meta on the affected posts; see delete-postmeta-that-skip-author-term-backfill above.

Clone this wiki locally