wp_clone_post
Copies a WordPress post from one environment to another as a new post, transferring all metadata. ID references are kept raw for manual remapping; supports field overrides.
Instructions
COPY a source post to another environment as a NEW post — the destination assigns its own ID (returned as new_id). Use this (NOT wp_sync_post) when the post does not exist on the destination yet, e.g. pushing a locally-authored alert/notification up to a Pantheon multidev. It reads the source post's fields (title, content, excerpt, status, type, dates, parent, etc.) plus ALL meta, creates the post on the destination via wp_insert_post, writes the meta verbatim, then verifies (content md5 + meta digest). Meta values that look like ID references (e.g. _thumbnail_id, ACF relationship/image fields) are copied RAW and REPORTED in id_reference_keys for manual remapping — the tool never silently remaps IDs across databases. Pass overrides to set post fields on the new post (e.g. {"post_status":"draft"}). Content/meta never pass through the caller's text. Creating on a production destination requires confirm=true when the PROD_GUARD is enabled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Destination environment to create the new post IN. Must differ from 'from'. | |
| from | Yes | Source environment to read the post FROM. | |
| site | No | Which configured site to target. 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 create on a production destination when the guard is enabled. Default: false. | |
| post_id | Yes | The SOURCE post ID to clone. The destination will get a NEW, different ID. | |
| from_env | No | Terminus environment override for the SOURCE when from='production'. Omit for TERMINUS_ENV. | |
| overrides | No | Optional post fields to set/replace on the new post (e.g. {"post_status":"draft","post_title":"..."}). |