Skip to content

Duplicate Posts ​

Copy posts and pages to a new draft, or rewrite a published one aside and republish it; reads Yoast Duplicate Post's data.

kitloom/duplicate-posts · admins: kitloom/duplicate-posts-filament, kitloom/duplicate-posts-nova

Video lessons ​

Recorded in the Filament admin; the Nova admin works the same way.

Copy a post to a new draft

Copy a post, a page or a record of another type in one click — to a new draft you open at once, or as a clone left in the list — and change a published page without taking it offline: Rewrite & Republish makes a working copy, you edit it while the page stays live, then the copy goes over the original, which keeps its address, date and comments.

It reads and writes Yoast Duplicate Post's data, so a site that ran the plugin keeps its settings, its copies know their originals, and a copy scheduled to republish still does. The admin is kitloom/duplicate-posts-filament or kitloom/duplicate-posts-nova.

Where the actions are ​

ActionWhat it doesWhere
New draftCopies the record and opens the copyA row's menu in the list, the edit page
CloneCopies the record and leaves you in the listA row's menu, the bulk actions
Rewrite & RepublishMakes a working copy of a published recordA row's menu, the edit page
RepublishWrites the working copy over its original and deletes the copyThe copy's row and edit page

Duplicate Posts → Settings chooses which of them are offered, on which post types (posts and pages at first) and where.

What a copy takes ​

Duplicate Posts settings

On What a copy takes you tick what new drafts and clones take from the original: title, date, status, slug, excerpt, content, featured image, template, post format, author, password, menu order. By default they take the title, excerpt, content, image, template, format and menu order — and they are drafts by you.

  • Title prefix and suffix go around the copy's title: "Copy of", "(copy)".
  • Increase the menu order by puts copies after their originals.
  • Meta not copied: custom field keys a copy must not take, separated by commas; * stands for any part of a key (_seo_*).
  • Taxonomies not copied: the categories, tags or other terms a copy is not filed under.

Custom fields, SEO settings and other meta are copied as they are, and so are the terms. Some things never go along: the editing lock, the old addresses WordPress keeps for redirects, revisions (a copy starts its own history). Other modules take care of their own data:

  • Languages — the translations go along, each at an address of its own in the language (a-propos-2).
  • Shop — a copied product has no SKU, no sales and no rating, as WooCommerce's own Duplicate makes it, and takes its variations.
  • Future Actions — a scheduled unpublish or trash stays with the original.
  • Themes with fields in tables (Saffron's recipe cards) — the card is copied.

A copy of a published record with Status ticked is published too — or waits for review when you may not publish.

Rewrite & Republish ​

Rewrite & Republish a page
  1. On a published record choose Rewrite & Republish. A draft copy of all of it opens — everything is taken, whatever the settings above say, but the slug.
  2. Edit the copy as long as you need; the original stays live as it was.
  3. Press Republish. The original takes the copy's title, text, excerpt, featured image, terms, custom fields and other meta, keeps its address, date, status and comments, and the copy is deleted. The original's revisions keep what it was before, so it can be restored.

To republish later, give the copy a date ahead and publish it: it is scheduled, and when the date comes it republishes instead of going live on its own. A product's stock, SKUs and sales stay as the shop counted them meanwhile.

A record has one working copy at a time. Deleting or trashing the copy frees the record for another one.

Who may copy ​

Users whose role has Copy posts on Users → Roles — administrators and editors at first, as Yoast Duplicate Post gives it — and who may edit the record they copy. Republishing asks the right to publish the type as well. The settings page is for those who manage the site's settings.

AI agents and webhooks ​

With kitloom/ai, agents get duplicate_posts_copy, duplicate_posts_rewrite and duplicate_posts_republish, acting with the rights of the user whose key they hold. With kitloom/webhooks, post.duplicated and post.republished can be sent to other services.

For developers ​

WhatWhere
SettingsYoast Duplicate Post's options: duplicate_post_copytitle … duplicate_post_copymenuorder, duplicate_post_title_prefix, duplicate_post_title_suffix, duplicate_post_increase_menu_order_by, duplicate_post_blacklist, duplicate_post_taxonomies_blacklist, duplicate_post_types_enabled, duplicate_post_show_link, duplicate_post_show_link_in, duplicate_post_show_original_column, duplicate_post_show_original_meta_box
A copy's marks_dp_original (the original's id); a working copy also _dp_is_rewrite_republish_copy and _dp_creation_date_gmt, its original _dp_has_rewrite_republish_copy
Permissioncopy_posts
ServicesKitloom\DuplicatePosts\Duplicator::copy($post, $actor), Kitloom\DuplicatePosts\Rewrites::start($post, $actor) and ::republish($copy, $actor)
EventsEvents\PostDuplicated (original, copy, actor, rewrite), Events\PostRepublished (original, the copy's id, actor)
Configurationconfig/kitloom-duplicate-posts.php: ai.register, webhooks.register, filament.register, nova.register

A module whose data of a post is more than plain meta — a table of its own, children, a value that must stay unique — implements Kitloom\DuplicatePosts\Contracts\CopiedWithPost and tags it with CopiedWithPost::TAG behind interface_exists(CopiedWithPost::class), with kitloom/duplicate-posts in suggest: excludedMeta($from, $to) names the keys that do not go along as they are, copy($from, $to, $actor) carries the rest — for a new copy, and back over the original on a republish.

php
use Kitloom\DuplicatePosts\Duplicator;
use Kitloom\DuplicatePosts\Rewrites;

$copy = app(Duplicator::class)->copy($post, $user);          // a draft, as the settings say
$working = app(Rewrites::class)->start($page, $user);         // edit it aside
app(Rewrites::class)->republish($working, $user);             // over the original

Tests ​

From the application that installs the package: php vendor/bin/phpunit --testsuite DuplicatePosts.

kitloom — modules and themes for Laravel.
Contact · Pricing · Services · License · Refunds · Privacy · Community · YouTube · [email protected]