Learn how to duplicate a page in WordPress

Domain Registration x Trademark Registration: Everything you need to know
Guide to learning how to connect PHP with MySQL

It has been in a situation where you want to give a makeover in the design of your current page, but at the same time, wants to keep its contents intact for future use? Of course, you can easily copy, paste, and save everything in a draft, but would not take along the optimization of SEO , page templates them, images and so on. 

There are also other situations where you want to clone a blog post just to make some adjustments in a copy of it and compare it with the original version. Well, there could be many circumstances where you only need to duplicate a page in WordPress. Or even a post.

It is useless to invest your time in something that would take as much as you can save time by simply duplicating a page or a post on WordPress with a single click. In this tutorial, you will learn how to duplicate a page in WordPress with the help of a few plugins. This is the simplest way to do this.

Let’s start!

What will you need

Before beginning this guide, you will need the following:

  • Access to your WordPress admin panel. 

Option 1 – How to duplicate a page in WordPress plugin with Duplicate Post

Plugin Duplicate Post is one of the easiest ways to clone or duplicate a post or a page in WordPress. It not only allows you to create a clone of content, but you can also put your own customization options.

You can have, for example, a prefix or a predefined suffix that can be added before or after the title of the page or post duplicate. In addition, you can also restrict the functionality of the plugin according to the permissions that the user who is working at the moment have.

To duplicate a post or page using this plugin, follow the steps below:

  1. Install and activate the plugin.
    post duplicate plugin
  2. Now, click Pages> All Pages .
  3. Now go to the post or page you want to duplicate and you will see two new options there: Clone and New Draft .
    option to clone with the plugin duplicate post
  • Clicking Clone you create a cloned version of a particular post.
  • Clicking on New Draft you create a cloned version of a particular post and can still open it in the post editor. You can then start editing it and choose to save it as a draft or publish it definitely.

Option 2 – How to duplicate a page in WordPress plugin with the Duplicate Page and Post

The Duplicate Page and Post is another plugin that you can use to duplicate pages or posts quickly. This plugin helps you create a page or post duplicate while maintaining intact all their contents, including the title and the overall style.

Use this plugin is quite easy. You just need to follow the steps below.

  1. Install and activate the plugin.
    plugin duplicate page and post
  2. Now, go to Pages> All Pages if you want to create a cloned copy of a page. Or go to Posts> All posts if you want to create a cloned copy of a post.
  3. Go to the post that you want to clone and click Duplicate .
    option to double with the plugin duplicate post and page
  4. You will be redirected to a cloned copy of the post or cloned page. From here, you can edit the content as you want and then click Save as draft or  Post .
    save and publish a draft or content with plug-duplicate post and page

Option 3 – How to duplicate a page in WordPress with the plugin Post Duplicator 

If the previous plugins do not serve well to what you seek, you can choose to test the Post Duplicator. This plugin helps you create a perfect replica of post you choose, at the same time maintaining the customization fields and also custom taxonomies.

All you need to do is:

  1. Install and activate the plugin.
    duplicator post plugin in wordpress
  2. Now, go to the post or page you want to duplicate and click Duplicate Page or Duplicate Post , depending on what you want to do, and create a cloned copy of the file.
    option to double page with the plugin post duplicator in wordpress
  3. The plugin will instantly double the page or post.
    option to copy or duplicate page or post in wordpress

Option 4 – How to duplicate a page in WordPress without using plugins

Please note: We recommend backing up your site before editing any file on WordPress.

In addition to using plugins, you can also use the codes to duplicate WordPress posts or pages. If you like programming, you will find here. And even if you are not familiar with this practice, we are here to help. Below you can find the code snippet  that enables duplication of posts in WordPress.

  1. / *
  2. * Function for post duplication. Appear dups the 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 date Then
  20. * /
  21. $ post = get_post ( $ post_id ) ;
  22. / *
  23. * If you do not 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 duplicate post
  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 terms post ad in September Them to the new post draft
  56. * /
  57. $ taxonomies = get_object_taxonomies ( $ post-> post_type ) ; // returns array of names for post taxonomy type, eg array ( “category”, “post_tag”);
  58. foreach ( $ taxonomies the $ 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 just goal 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 the $ 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 ) ;
/ *
 * Function for post duplication. Appear dups the drafts. User is redirected to the edit screen
 * /
rd_duplicate_post_as_draft function () {
  global $ wpdb;
  if (! (Isset ($ _GET [ 'post']) || Isset ($ _POST [ 'post']) || (Isset ($ _ REQUEST [ 'action']) && 'rd_duplicate_post_as_draft' == $ _REQUEST [ 'action ']))) {
    wp_die ( 'No post to duplicate Has Been supplied!');
  }
 
  / *
   * Nonce verification
   * /
  if (! isset ($ _GET [ 'duplicate_nonce']) ||! wp_verify_nonce ($ _GET [ 'duplicate_nonce'] basename (__FILE__)))
    return;
 
  / *
   * Get the original post id
   * /
  $ Post_id = (isset ($ _ GET [ 'post']) absint ($ _GET [ 'post']): absint ($ _POST [ 'Post']));
  / *
   * And all the original post date Then
   * /
  $ Post = get_post ($ post_id);
 
  / *
   * If you do not want current user to be the new post author,
   * Then change next couple of lines to this: $ new_post_author = $ post-> post_author;
   * /
  Current_user wp_get_current_user $ = ();
  $ New_post_author = $ current_user-> ID;
 
  / *
   * If post data exists, create the duplicate post
   * /
  if (isset ($ post) && $ post! = null) {
 
    / *
     * New post data array
     * /
    $ Args = array (
      'Comment_status' => $ post-> comment_status,
      'Ping_status' => $ post-> ping_status,
      'Post_author' => $ new_post_author,
      'Post_content' => $ post-> post_content,
      'Post_excerpt' => $ post-> post_excerpt,
      'POST_NAME' => $ post-> POST_NAME,
      'Post_parent' => $ post-> post_parent,
      'Post_password' => $ post-> post_password,
      'Post_status' => 'draft'
      'Post_title' => $ post-> post_title,
      'Post_type' => $ post-> post_type,
      'To_ping' => $ post-> to_ping,
      'Menu_order' => $ post-> menu_order
    );
 
    / *
     * Insert the post by wp_insert_post () function
     * /
    New_post_id wp_insert_post $ = ($ args);
 
    / *
     * Get all current terms post ad in September Them to the new post draft
     * /
    $ Taxonomies = get_object_taxonomies ($ post-> post_type); // returns array of names for post taxonomy type, eg array ( "category", "post_tag");
    foreach ($ taxonomies the $ taxonomy) {
      Post_terms wp_get_object_terms $ = ($ post_id, $ taxonomy, array ( 'fields' => 'slugs'));
      wp_set_object_terms ($ new_post_id, $ post_terms, $ taxonomy, false);
    }
 
    / *
     * Duplicate all post just goal in two SQL queries
     * /
    $ Post_meta_infos = $ wpdb-> get_results ( "SELECT meta_key, meta_value FROM $ wpdb-> postmeta WHERE post_id = $ post_id");
    if (count ($ post_meta_infos)! = 0) {
      $ Sql_query = "INSERT INTO $ wpdb-> postmeta (post_id, meta_key, meta_value)";
      foreach ($ post_meta_infos the $ meta_info) {
        $ Meta_key = $ meta_info-> meta_key;
        if ($ meta_key == '_wp_old_slug') continue;
        meta_value = $ addslashes ($ meta_info-> meta_value);
        $ Sql_query_sel [] = "SELECT $ new_post_id, '$ meta_key', '$ meta_value'";
      }
      $ Sql_query = implode ( "UNION ALL" $ sql_query_sel.);
      $ Wpdb-> query ($ sql_query);
    }
 
 
    / *
     * Finally, redirect to the edit post screen for the new draft
     * /
    wp_redirect (ADMIN_URL ( 'post.php action = edit & post =' $ new_post_id).);
    exit;
  } Else {
    wp_die ( 'Post creation failed, Could Not find original post:'. $ post_id);
  }
}
add_action ( 'admin_action_rd_duplicate_post_as_draft' 'rd_duplicate_post_as_draft');
 
/ *
 * Add the duplicate link to action list for post_row_actions
 * /
rd_duplicate_post_link function ($ actions, $ post) {
  if (current_user_can ( 'edit_posts')) {
    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> ';
  }
  return $ actions;
}
 
add_filter ( 'post_row_actions' 'rd_duplicate_post_link', 10, 2);

In addition to this snippet be used to duplication of posts, you can also use it to duplicate pages in WordPress. Simply replace the last line of code for this line:

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

All you need to do is put this code in the file functions.php . To do this, you can use either the File Manager , the FTP client FileZilla or the own WordPress file editor, as shown below.add code in wordpress to duplicate page or post

Once you do, you can go on All Pages or All posts and duplicate any of them by pressing the Duplicate . When you do, WordPress will create a copy of the page or post you selected and will save it as a draft. Quiet, right?

Drago learned how to duplicate a page in wordpress

Conclusion

We are sure you must be wondering why you never heard about these plugins before. But better late than never! We hope the above tutorial has answered all your questions and now you know how to duplicate a page in WordPress.

All plugins mentioned above do not only fast, but also very reliable. So why invest so much time in a complex task when you can do it in just a few clicks?

Do you have any request or any experience you want to share? Tell it to us in the comments below. For more WordPress tutorials and guides, be sure to visit the content on WordPress in our blog !