wp_sync_option
Sync WordPress wp_options rows (settings, ACF options) between environments with md5 verification. Select rows by exact names or LIKE pattern. Handles multisite subdomains automatically. Requires confirm for production writes.
Instructions
SYNC one or more wp_options rows (site/plugin settings, and ACF OPTIONS-PAGE data) from one environment to another, with a mandatory md5 round-trip verification. This is the options-table counterpart to wp_sync_post_meta: use it for settings that live in wp_options, which the post tools cannot reach (they only handle a post's content and post meta). Select rows two ways: option_names=[...] for exact names, OR like='prefix%' for a SQL LIKE pattern. NOTE for ACF repeaters/nested groups: a repeater is stored as a parent count row (options_), numbered sub-rows (options_), AND a parallel set of underscore-prefixed field-key references (options...). To copy one completely, match BOTH prefixes — run once with like='options_%' and once with like='options%', or enumerate the rows in option_names. Matching only 'options_%' omits the field references and ACF will not render the group. Each stored option_value is PHP serialize()'d on the source, base64-encoded IN CODE, and rebuilt verbatim on the destination (delete-then-add, values re-interpreted only via maybe_unserialize so arrays/objects round-trip byte-for-byte). The destination is re-read and md5-compared; a mismatch returns verified=false, never silently trusted. Multisite: pass from_subdomain / to_subdomain as a BARE subdomain to target a subsite per side; URL handling is AUTOMATIC PER-SIDE — each side is checked against its own environment and the correct --url is resolved from that environment's live blog table (a given subdomain → that blog; none → the main 'www' site), and single-site environments get no --url. You never construct a URL, and it stays correct even when local and production use different domains. Content never passes through the caller's text. Transport (local Docker vs Terminus vs SSH) is resolved per side from wp-cli.conf exactly like wp_cli. Writing to a production destination requires confirm=true when the PROD_GUARD is enabled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Destination environment to write options TO. May equal 'from' when copying between two DIFFERENT subsites of one multisite (set from_subdomain != to_subdomain); otherwise it must differ from 'from'. | |
| from | Yes | Source environment to read options FROM. | |
| like | No | SQL LIKE pattern selecting every matching option_name (e.g. 'options_my_repeater%'). Mutually exclusive with 'option_names'. For ACF repeaters, also copy the '_options_<field>%' field-reference rows. | |
| site | No | Which configured site to target (matches a [site:NAME] section in wp-cli.conf). Omit for DEFAULT_SITE or the sole site. | |
| to_env | No | Terminus environment override for the DESTINATION when to='production'. Omit for TERMINUS_ENV. | |
| confirm | No | Required to write to a production destination when the guard is enabled. Default: false. | |
| from_env | No | Terminus environment override for the SOURCE when from='production'. Omit for TERMINUS_ENV. | |
| option_names | No | Exact option names to copy. Mutually exclusive with 'like'; one of the two is required. | |
| to_subdomain | No | Bare subdomain of the DESTINATION multisite subsite. Omit for the main 'www' site. Ignored on single-site environments. The full --url is resolved from the destination environment automatically. | |
| from_subdomain | No | Bare subdomain of the SOURCE multisite subsite (e.g. 'shop'). Omit for the main 'www' site. Ignored on single-site environments. The full --url is resolved from the source environment automatically. |