Duplicate a post or page
wp_duplicate_postCopy an existing post or page into a new draft while the original stays unchanged. Use the copy as a starting point, with supported taxonomy terms and page builder layouts preserved when permitted.
Instructions
Copy an existing post or page into a new draft, as a starting point for a new page; the original stays unchanged and each call creates another copy. The draft gets the title with " (Copy)" appended, the content, excerpt, parent, menu order and the terms of taxonomies the account may assign (of those, the terms it may assign one by one, assign_term), and, for an account that may edit the original, its custom fields, featured image, page template and page builder layout, so a page built with Elementor, Beaver Builder, SiteOrigin or another builder that stores its layout in post meta stays a builder page. Page builder data holds markup and is copied only with the unfiltered_html capability; a builder's keys, its page template included, are copied together or not at all; Elementor element ids are renewed. Never copied: credential-like keys, the original's editing state (edit lock, last editor, former slugs, trash data), caches the builder rebuilds, protected keys of other plugins, and a revision's meta. Media files cannot be duplicated, and a password-protected post only by an account that may edit it. Returns {duplicated: true, new_id}, the copied and skipped keys (with reasons) and the original's builder. Needs the right to read the original and to create entries of its type.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Id of the post or page to copy. |