How to Duplicate WordPress Page or Post

Creating a duplicate of your existing WordPress posts or pages can be useful in many situations. You can use the copy as a template for future posts, or a reference when you redesign your website.

Thankfully, there are multiple ways to clone a page or post in WordPress. This tutorial will explain those different methods, so sit tight and keep reading!

Duplicating Page or Post with WordPress Plugin

The easiest way to create a copy of a page or post is by using a plugin. Upon activation, cloning posts and pages is only a click away!

Take a look at our selection of the best WordPress plugins to duplicate your posts and pages as well as how to use them:

1. Duplicate Post Plugin

Duplicate Post is a great plugin to clone a WordPress page or post.

Duplicate Post plugin is one of the go-to options for this purpose. Aside from copying the content, you can also duplicate the comments, slug, menu order, and much more!

In addition, the plugin allows you to add title prefix or a suffix, so you’ll know which one is the original and which one is the copy.

Let’s say you set “Copy of” as the title prefix. If you duplicate a post titled “What is WordPress,” the duplicate will be named “Copy of What is WordPress.”

To clone your WordPress posts or pages using Duplicate Post, follow these simple steps:

  1. Install and activate the plugin.
  2. Go to your WordPress dashboard, then click on Pages -> All Pages (if you want to clone a page) or Post -> All Post (if you’re going to clone a post).
  3. Hover over the page or post you want to clone, and you will see two new options there — Clone and New Draft.
  4. Click Clone to duplicate the selected post, or choose New Draft to create a cloned version of the chosen post and open it in the post editor.

2. Duplicate Page and Post

Duplicate Page and Post plugin helps you to clone your pages or posts

Duplicate Page and Post enables you to clone WordPress pages and posts quickly. The plugin can duplicate a page or post without changing its content, title, or style.

Using this plugin is relatively easy. You just need to follow these steps:

  1. After installing and activating the plugin, go to the All Pages or All Posts menu, depending on what you want to duplicate.
  2. Hover over the post or page you want to clone and click Duplicate.
  3. The cloned post or page will appear as a new draft with the same name as the original. Open the copy to edit the content.

3. Post Duplicator

Post Duplicator is an amazing WordPress plugin to clone your posts or pages.


Post Duplicator allows you to create an exact replica of the selected post while retaining the custom fields and custom taxonomies as well.

Here’s how to duplicate a WordPress page or post using Post Duplicator plugin:

  1. Install and activate the Post Duplicator plugin.
  2. Hover over the post or the page you want to duplicate, and click Duplicate Post or Duplicate Page.

There are some settings that you can customize for the duplicated posts. Go to Tools -> Post Duplicator and set the post status (draft, published, or same as the original), post type, and post date. It’s also possible to adjust the duplicate’s title and slug.

Duplicating WordPress Page or Post Without Plugins

Besides using plugins, you can also tweak some codes to duplicate WordPress pages and posts. While this method sounds like a bother, it is actually quite simple.

We strongly recommend to backup your website before editing any WordPress files.

The code snippet below will enable post duplication in WordPress:

  1. /*
  2. * Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
  3. */
  4. function rd_duplicate_post_as_draft(){
  5. global $wpdb;
  6. if (! ( isset( $_GET[‘post’]) || isset( $_POST[‘post’]) || ( isset($_REQUEST[‘action’]) && ‘rd_duplicate_post_as_draft’ == $_REQUEST[‘action’] ) ) ) {
  7. wp_die(‘No post to duplicate has been supplied!’);
  8. }
  9. /*
  10. * Nonce verification
  11. */
  12. if ( !isset( $_GET[‘duplicate_nonce’] ) || !wp_verify_nonce( $_GET[‘duplicate_nonce’], basename( __FILE__ ) ) )
  13. return;
  14. /*
  15. * get the original post id
  16. */
  17. $post_id = (isset($_GET[‘post’]) ? absint( $_GET[‘post’] ) : absint( $_POST[‘post’] ) );
  18. /*
  19. * and all the original post data then
  20. */
  21. $post = get_post( $post_id );
  22. /*
  23. * if you don’t want current user to be the new post author,
  24. * then change next couple of lines to this: $new_post_author = $post->post_author;
  25. */
  26. $current_user = wp_get_current_user();
  27. $new_post_author = $current_user->ID;
  28. /*
  29. * if post data exists, create the post duplicate
  30. */
  31. if (isset( $post ) && $post != null) {
  32. /*
  33. * new post data array
  34. */
  35. $args = array(
  36. ‘comment_status’ => $post->comment_status,
  37. ‘ping_status’ => $post->ping_status,
  38. ‘post_author’ => $new_post_author,
  39. ‘post_content’ => $post->post_content,
  40. ‘post_excerpt’ => $post->post_excerpt,
  41. ‘post_name’ => $post->post_name,
  42. ‘post_parent’ => $post->post_parent,
  43. ‘post_password’ => $post->post_password,
  44. ‘post_status’ => ‘draft’,
  45. ‘post_title’ => $post->post_title,
  46. ‘post_type’ => $post->post_type,
  47. ‘to_ping’ => $post->to_ping,
  48. ‘menu_order’ => $post->menu_order
  49. );
  50. /*
  51. * insert the post by wp_insert_post() function
  52. */
  53. $new_post_id = wp_insert_post( $args );
  54. /*
  55. * get all current post terms ad set them to the new post draft
  56. */
  57. $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array(“category”, “post_tag”);
  58. foreach ($taxonomies as $taxonomy) {
  59. $post_terms = wp_get_object_terms($post_id, $taxonomy, array(‘fields’ => ‘slugs’));
  60. wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
  61. }
  62. /*
  63. * duplicate all post meta just in two SQL queries
  64. */
  65. $post_meta_infos = $wpdb->get_results(“SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id”);
  66. if (count($post_meta_infos)!=0) {
  67. $sql_query = “INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) “;
  68. foreach ($post_meta_infos as $meta_info) {
  69. $meta_key = $meta_info->meta_key;
  70. if( $meta_key == ‘_wp_old_slug’ ) continue;
  71. $meta_value = addslashes($meta_info->meta_value);
  72. $sql_query_sel[]= “SELECT $new_post_id, ‘$meta_key’, ‘$meta_value'”;
  73. }
  74. $sql_query.= implode(” UNION ALL “, $sql_query_sel);
  75. $wpdb->query($sql_query);
  76. }
  77. /*
  78. * finally, redirect to the edit post screen for the new draft
  79. */
  80. wp_redirect( admin_url( ‘post.php?action=edit&post=’ . $new_post_id ) );
  81. exit;
  82. } else {
  83. wp_die(‘Post creation failed, could not find original post: ‘ . $post_id);
  84. }
  85. }
  86. add_action( ‘admin_action_rd_duplicate_post_as_draft’, ‘rd_duplicate_post_as_draft’ );
  87. /*
  88. * Add the duplicate link to action list for post_row_actions
  89. */
  90. function rd_duplicate_post_link( $actions, $post ) {
  91. if (current_user_can(‘edit_posts’)) {
  92. $actions[‘duplicate’] = ‘<a href=”‘ . wp_nonce_url(‘admin.php?action=rd_duplicate_post_as_draft&post=’ . $post->ID, basename(__FILE__), ‘duplicate_nonce’ ) . ‘” title=”Duplicate this item” rel=”permalink”>Duplicate</a>’;
  93. }
  94. return $actions;
  95. }
  96. add_filter( ‘post_row_actions’, ‘rd_duplicate_post_link’, 10, 2 );

This snippet only works for duplicating posts. You can duplicate WordPress pages by replacing the last line with this code:

  1. add_filter(‘page_row_actions’, ‘rd_duplicate_post_link’, 10, 2);

All you need to do is paste the code to your functions.php file. To do this, you can either use File Manager, FTP client, or inbuilt WordPress file editor.

You need to edit the functions.php file to clone a page or post manually.

If you plan to use the third option, navigate to Appearance -> Theme Editor, and select Theme Functions.

The duplicate option will be available if you successfully edit the functions.php file.

Now, if you have successfully embedded the code above, you should see a Duplicate button in All Posts or All Pages menu.

Conclusion

We hope this tutorial answers all your questions about how to duplicate a post or page in WordPress. To refresh our minds, let’s have a quick recap.

First, you can duplicate a page or post using a WordPress plugin. For this purpose, there are three different plugins you can choose: Duplicate Post, Duplicate Page and Post, and Post Duplicator.

Second, you can do it without a plugin. All you need to do is access the functions.php file in WordPress, then enter the code that we’ve provided.

Do you have any questions, tips, or tricks? Let us know in the comment section below!

Leave a Comment

submit loader