Skip to content

[00] Subset Clone, For developers

WP-CLI commands

Every wp subset duplicator command in Subset Clone and Clone Pro, with its options, defaults and examples as wp help prints them.

Subset Clone adds its commands under wp subset duplicator. On multisite, Subset Clone Pro adds --to-site to duplicate and a cross-site settings group. Run wp help subset duplicator <command> on your site to see the same text there.

duplicate

Duplicates one or more posts. Each copy is a draft.

The command runs as the user you give with --user, with the same permission check and settings as the Duplicate buttons. That user must be able to read each post and create posts of its type. Without --user, the command stops with an error. A post that can’t be duplicated is reported and the rest carry on, and the command then exits with status 1.

wp subset duplicator duplicate <id>... [--title=<title>] [--author=<user>] [--attachments] [--porcelain] [--format=<format>]
OptionDefaultWhat it does
<id>...NoneThe posts to duplicate.
--title=<title>The original’s title marked as a copy, or the settings’ title formatThe copies’ title.
--author=<user>The --user, or the original’s author when the settings say soThe copies’ author, as a user ID, login or email.
--attachmentsThe settingGives the copies their own attached media, sharing the original files. --no-attachments leaves them out.
--porcelainOffPrints only the copies’ IDs, one per line.
--format=<format>tableOutput format: table, json, csv or ids.
--to-site=<site>NonePro, multisite only. See duplicate —to-site.

The table output has the columns original, copy, title, status and edit_link.

wp subset duplicator duplicate 12 --user=1
wp subset duplicator duplicate 12 15 --user=admin --title="Draft for review" --porcelain

settings

Lists, reads and changes the settings on the settings screen. Only known names are accepted, and changes are cleaned the same way the settings screen cleans them, except that unknown post types, roles and author choices are refused. A setting pinned by a constant in wp-config.php can’t be changed here either.

wp subset duplicator settings list [--format=<format>]
wp subset duplicator settings get <name> [--format=<format>]
wp subset duplicator settings set <name> <value>
wp subset duplicator settings reset [--yes]
SubcommandOptionsWhat it does
list--format: table (default), json, csv or yamlLists every setting, its value and its source: default, saved, filter or constant.
get--format: plain (default) or jsonPrints one setting’s value.
setNoneChanges one setting. Booleans take true/false, yes/no, on/off or 1/0. Lists take a JSON array or comma-separated values.
reset--yes skips the confirmationRemoves every saved setting, so each goes back to its default. A setting pinned by a constant keeps the constant’s value.

The settings are:

  • disabled_post_types: types that are on by default, switched off
  • enabled_post_types: other types, switched on
  • title_format
  • author: original (the default) or current
  • copy_attachments
  • excluded_roles
wp subset duplicator settings list
wp subset duplicator settings set copy_attachments true

duplicate —to-site (Pro)

On multisite, Subset Clone Pro adds --to-site to duplicate. Each post is copied to that site of the network instead of being duplicated on the current one, after the same permission check as the Copy to site screen. The output gains a site column. The user needs a role on the other site that can create posts of that type. See Copy to another site.

wp subset duplicator duplicate <id>... --to-site=<site>
OptionDefaultWhat it does
--to-site=<site>NoneThe site to copy to, as a site ID or URL. A URL must match the site’s domain and path exactly, with or without the scheme.
wp subset duplicator duplicate 42 --user=admin --to-site=3
wp subset duplicator duplicate 42 --user=admin --to-site=shop.example.com

cross-site settings (Pro)

On multisite, cross-site settings reads and changes Pro’s network-wide cross-site settings. There’s one: missing_terms, which decides what happens to a term the other site doesn’t have. Set it to create (the default) to create the term there, or skip to leave it off the copy.

wp subset duplicator cross-site settings list [--format=<format>]
wp subset duplicator cross-site settings get <name>
wp subset duplicator cross-site settings set <name> <value>
wp subset duplicator cross-site settings reset [--yes]
SubcommandOptionsWhat it does
list--format: table (default), json, csv or yamlLists every setting, its value and its source: default or saved.
getNonePrints one setting’s value.
setNoneChanges one setting.
reset--yes skips the confirmationRemoves every saved setting, so each goes back to its default.
wp subset duplicator cross-site settings list
wp subset duplicator cross-site settings get missing_terms
wp subset duplicator cross-site settings set missing_terms skip