wp_sync_post
Sync a post's content to the same ID on another environment with mandatory md5 verification, updating the destination post without creating new ones.
Instructions
SYNC a single post's post_content onto the SAME post ID in another environment, with a mandatory md5 round-trip verification. This UPDATES an existing destination post that shares the source's ID (e.g. a multidev cloned from the same DB) — it does NOT create a post; if the destination ID is missing it fails. To copy a post that does NOT yet exist on the destination (creating a new post with a destination-assigned ID), use wp_clone_post instead. Use this instead of hand-assembling post update/eval calls to push post body content between local and production (e.g. update a front-page's block markup on a Pantheon multidev). The content NEVER passes through the caller's text: it is read from the source into the server, base64-encoded IN CODE, applied on the destination through a transport-safe PHP eval (STDIN eval-file for Docker/SSH so arbitrarily large posts work; size-guarded argv for Terminus), then re-read and md5-compared to the source. If the hashes differ, the tool reports verified=false and returns an error rather than leaving the destination silently unverified. Transport for each side (local Docker vs Terminus vs SSH) is resolved 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 post_content TO. Must differ from 'from'. | |
| from | Yes | Source environment to read post_content FROM. | |
| site | No | Which configured site to target (matches a [site:NAME] section in wp-cli.conf). Omit to use DEFAULT_SITE or the sole site. | |
| to_env | No | Terminus environment override for the DESTINATION when to='production' on a Terminus site. Omit to use TERMINUS_ENV. | |
| confirm | No | Required to write to a production destination when the guard is enabled. Default: false. | |
| post_id | Yes | The post ID to sync. Must be the SAME ID on both source and destination (they are assumed in sync, e.g. a multidev cloned from the same DB). The tool verifies the destination post exists and fails if it does not — use wp_clone_post to create a new post instead. | |
| from_env | No | Terminus environment override for the SOURCE when from='production' on a Terminus site. Omit to use TERMINUS_ENV. | |
| only_blocks | No | Optional allow-list of blockNames (e.g. 'acf/sps-celebrations-block'). When set, ONLY these top-level blocks are carried from the source; every OTHER block on the destination is kept as-is (the source and destination bodies are spliced block-by-block). Use this to push a changed block without clobbering blocks the destination edited independently. Mutually exclusive with except_blocks. For per-block edits prefer wp_block. | |
| except_blocks | No | Optional deny-list of blockNames to LEAVE ALONE on the destination while syncing everything else from the source (e.g. except_blocks=['acf/sps-hero-slideshow-block'] pushes the body but preserves the destination's hand-built slideshow). Mutually exclusive with only_blocks. |