wp_sync_post_meta
Copy all custom fields (meta) from a post to the same post ID in another environment with checksum verification. Updates existing destination post.
Instructions
SYNC a post's COMPLETE meta (all custom fields) onto the SAME post ID in another environment, with a mandatory checksum round-trip verification. This UPDATES an existing destination post that shares the source's ID; it does NOT create a post (use wp_clone_post to copy a post that doesn't exist on the destination yet). Preserves EVERYTHING: multiple values per key, serialized arrays/objects (e.g. ACF repeaters), and exact scalar representations — the raw stored meta map is PHP serialize()'d on the source, base64-encoded IN CODE, and rebuilt on the destination with each stored value written back verbatim (no re-interpretation). It then re-reads the destination and compares a canonical PHP-native digest to the transferred payload; a mismatch is returned as verified=false, never silently trusted. By default ALL meta keys are synced and any destination keys not present on the source are removed (full mirror). Pass keys=[...] to sync only specific keys (destination keys outside that list are left untouched). 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 meta TO. Must differ from 'from'. | |
| from | Yes | Source environment to read meta FROM. | |
| keys | No | Optional allow-list of meta keys to copy (each must match [A-Za-z0-9_:.-]+). Omit to copy ALL keys and mirror the source (destination-only keys are deleted). When provided, only these keys are touched on the destination. | |
| 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. | |
| post_id | Yes | The post ID whose meta to sync (SAME ID on both sides). | |
| from_env | No | Terminus environment override for the SOURCE when from='production'. Omit for TERMINUS_ENV. |