WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Duplicate Post

Clone posts and pages.

Template tags

I have added the template tag duplicate_post_clone_post_link( $link, $before, $after, $id ), which behaves just like edit_post_link(). That means that you can put it in your template (e.g., in single.php or page.php) so you can get a "Clone" link when displaying a post or page.

The parameters are:

  • link (string) (optional) The link text. Default: __('Clone','duplicate-post')

  • before (string) (optional) Text to put before the link text. Default: None

  • after (string) (optional) Text to put after the link text. Default: None

  • id (integer) (optional) Post ID. Default: Current post ID

Another available template tag is duplicate_post_get_original($id, $output) which returns the original post, either as a post object, an associative array or a numeric array (depending on the $output parameter), jus as get_post() does.

duplicate_post_get_original()

relies on the _dp_original custom field.

For plugin developers

From version 1.0 onwards, thanks to Simon Wheatley's suggestion, Duplicate Post adds two actions (dp_duplicate_post and dp_duplicate_page) which can be used by other developers if their plugins store extra data for posts in non-standard WP tables. Since Duplicate Post knows only of standard WP tables, it can't copy other data relevant to the post which is being copied if this information is stored elsewhere. So, if you're a plugin developer which acts this way, and you want to ensure compatibility with Duplicate Post, you can hook your functions to those actions to make sure that they will be called when a post (or page) is cloned.

It's very simple. Just write your function that copies post metadata to a new row of your table:

function myplugin_copy_post($new_post_id, $old_post_object){
/* your code */
}

Then hook the function to the action:

add_action( "dp_duplicate_post", "myplugin_copy_post", $priority, 2);

dp_duplicate_page is used for pages and hierarchical custom post types; for every other type of posts, dp_duplicate_post is used.

Please refer to the Plugin API for every information about the subject.

Contribute

If you find this useful and you if you want to contribute, there are three ways:

  1. You can write me and submit your bug reports, suggestions and requests for features;
  2. If you want to translate it to your language (there are just a few lines of text), you can use the GlotPress translation project, or contact me and I’ll send you the .pot catalogue; your translation could be featured in next releases;
  3. Using the plugin is free, but if you want you can send me some money with PayPal here

Requires: 3.0 or higher
Compatible up to: 3.8.3
Last Updated: 2014-2-27
Downloads: 702,887

Ratings

4 stars
4.9 out of 5 stars

Support

1 of 4 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

2 people say it works.
1 person says it's broken.

100,1,1 100,2,2
100,1,1 100,1,1 100,2,2 100,1,1
100,1,1 100,1,1
100,5,5 100,1,1
100,9,9 100,1,1 100,1,1
0,1,0 75,4,3 100,3,3
100,12,12
100,2,2
100,6,6 0,1,0 100,1,1
100,1,1
89,9,8 100,1,1
100,2,2
100,4,4
100,4,4
100,1,1
100,2,2 100,1,1
100,12,12 100,2,2 75,4,3 100,3,3
100,1,1 50,2,1 100,1,1 100,4,4 100,1,1 100,1,1 100,2,2
100,1,1 88,16,14 100,4,4 100,1,1 100,1,1
100,1,1 100,1,1 100,15,15
100,3,3
100,8,8
100,13,13
60,5,3
94,18,17
100,3,3
88,8,7
100,6,6
100,6,6
89,9,8 100,1,1 83,6,5
100,5,5
89,9,8
67,3,2