by trangnq
December 17, 2021

Simple ways to duplicate a wordpress page or post

In case you have been blogging for a while, you could sometimes need  to rapidly duplicate a post or page. For example, a sales page includes a lot of information you can reuse, or an older post that can be expanded into a new one. You now are able to copy and paste the contents of the post or page into a new draft manually. However, you must bear in mind that your featured picture, post settings, SEO settings, and other metadata are not copied. In this article, Arrowtheme delivers you simple yet extremely efficient ways for you to duplicate WordPress page successfully. Hence, explore with us right now! 

>>> Read more: How to add a navigation menu in WordPress

How to duplicate a WordPress page or post? 

To begin, you have to set up the Duplicate Post plugin and activate it right after. Then, you must go to the Posts >> All Posts page as soon as you activate it. Besides, below each post title, you will see two new links to clone or create a new draft.

how to duplicate wordpress page

After that, by selecting “Clone”, you will merely produce a replica post that will not open in the post editor. What’s more, the “New Draft” option is in charge of duplicating the post and opening the duplicate version in the post editor, allowing you to work on it immediately.

In terms of page, you can also see the same choices are available as well. In this case, a duplicate post plugin is considered as the best choice for you to duplicate wordpress page/ post. 

Customizing duplicate post plugin settings

The duplicate post plugin is ready to use right away and assists to duplicate wordpress page and post. Best of all, you can customize the plugin to support specific post types, limit user roles, and determine what to replicate when duplicating a post. Then, you should go over all of these settings:

In order to configure plugin settings, you must firstly go to Settings >> Duplicate Post page. 

simple ways to duplicate wordpress page

What’s more, there are three tabs on the settings page. When making a duplicate, the first tab enables you to choose what to copy. Besides, for most websites, the default settings should suffice. On the other hand, you are able to check the items you want to copy and uncheck the stuff you don’t want to duplicate. After that, you must go to the permissions tab. 

permissions tab

In addition, the duplicate wordpress page plugin allows administrator and editor user roles to duplicate posts by default. Alternatively, it also enables for the creation of duplicate postings for post kinds such as posts and pages. 

Moreover, in case you utilize custom post kinds on your website, they will show up here. Not only that, you also have the option of enabling the duplicate post feature for those post kinds as well. Finally, you must go to the Display tab and select where you want the clone post links to appear. Furthermore, the duplicate WordPress page plugin displays them by default in the post list, edit screen and admin bar. 

display button

The last stage you must remember is to click the Save button to complete your setting process. 

>>> Read more: How to fix error establishing a database connection in WordPress easily

Best duplicate WordPress page plugins 

1. Duplicate Post

Coming to worth-using plugins for duplicating WordPress pages and posts, the first one we highly recommend for you is Duplicate Post. In reality, this popular plugin is extremely simple to use and allows you to copy everything from the page or post’s content to the comments. In order to utilize this tool to duplicate wordpress page, you just need to simply follow the guide below: 

#1. Firstly, you must install the plugin and turn it on.

#2. When cloning posts, you must go to Posts >> All in your WordPress dashboard, and in terms of cloning pages, you have to go to Pages >> All. 

#3. Then, if you want to replicate a page or post, let’s go to the page or post you wish to copy and click Clone.

#4. After that, you need to select multiple pages or posts, and Bulk Actions can clone them all at once. 

2. Duplicate Page and Post

Another duplicate WordPress page plugin is Duplicate Page and Post. Although this plugin  may be lacking in functionality, it makes up for it in speed. In fact, this is one of the quickest ways to duplicate a post or page in WordPress, and it won’t clog up your site with extraneous features. Besides, you should use the methods below to clone a page or post using this plugin:

#1. Let’s start by setting up the plugin and then turning it on. 

#2. Depending on what you want to duplicate, you must go to Posts >> All for duplicating posts or Pages >> All with pages. 

#3. Then, you have to hover your page or post you want to duplicate.

#4 After that, you must select the Duplicate option. 

Duplicate Page and Post

3. Duplicate Page

Duplicate Page comes with some exceptional extra capabilities that other cloning plugins don’t. With the help of this plugin, you can easily duplicate posts, pages, and custom post kinds. What’s more, you can also keep the copies created as drafts, pending, public, or private. Then, you must follow these steps below if you want to use this duplicate wordpress page plugin.

#1. First and foremost, you have to install this wordpress plugin and activate it.

#2. Then, you must adjust the settings to suit your needs. 

#3. After that, to discover the information you wish to reproduce, you need to go to Pages >> All or Posts >> All

#4. Finally, you must select the Duplicate option. 

4. Post Duplicator

Post Duplicator is another awesome WordPress clone page plugin you should consider. Besides, this solution duplicates any post or page in its entirety, including custom post types, fields, and taxonomies. In fact, it is simple to set up and operate, and in particular, it shouldn’t add much to the weight of your website.

Now, let’s follow these procedures to replicate material thanks to using this tool: 

#1. Firstly, you have to set up and activate the plugin. 

#2. Then, in order to find the content you wish to clone, let’s go to Posts >> All or Pages >> All.

#3. The next step you must do is to hover your mouse over the post or page you want to see. 

#4. After all, don’t forget to choose the Duplicate Page or Duplicate Post option.  

How to duplicate WordPress page without using a plugin?

To clone a page or post in WordPress, you don’t need to utilize a plugin. Manually, this can be done by modifying the functions.php file or copying and pasting the required code. Then, you should have a look at how both of these strategies function. 

1. Use the funtions.php code to enable cloning 

Editing the code in your functions.php file is one of the ways to clone a WordPress page or post without a plugin. While this may seem simple, you should proceed with caution and create a backup of your website first. What’s more, you will need to access your functions.php file and open it for editing via Secure File Transfer Protocol (FTP) or another way to enable post cloning. Let’s add the following code to the end of the find to duplicate wordpress page.

/*

 * Function for post duplication. Dups appear as drafts. User is redirected to the edit screen

 */

function rd_duplicate_post_as_draft(){

  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 data then

   */

  $post = get_post( $post_id );

  /*

   * if you don’t 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 post duplicate

   */

  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 post terms ad set them to the new post draft

     */

    $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array(“category”, “post_tag”);

    foreach ($taxonomies as $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 meta just 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 as $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

 */

function rd_duplicate_post_link( $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 );

Then, you have to use the same code to allow cloning for pages as well, but don’t forget to change the final line with:

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

Most importantly, the file must be saved and re-uploaded to your server. After that, you can return to your WordPress dashboard. Then, when you hover over a page or post you want to clone, a Duplicate button should appear. 

wordpress clone page without using a plugin

In particular, if you can’t duplicate a wordpress page or post on your own, asking Arrowtheme is extremely necessary for you to save time. Following that, we offer WordPress website packages that have many options for you to choose. Best of all, we are running a discount program that gets upto 30% off for all WordPress services. Hence, no matter what your need and budget, our WordPress packages are the best choice for you. Let’s CONTACT US if you are interested and need a free consultancy.

2. Manually copy and paste code to duplicate a page/ post

In addition, you can manually copy and paste the code for the page or post you want to clone if you don’t want to change your functions.php file. In order to accomplish this, you need to follow steps below:

#1. Firstly, you have to open the page or post that you desire to duplicate. 

#2. Then, you must select More Tools & Options menu

#3. Choose Code Editor in order to continue

#4. After that, you need to copy the code for the page or post 

#5. Then, let’s select New Post or New Page 

#6. The next step you must do is to open the Code Editor in the new post or page. 

#7. Then, paste in the code to proceed

#8. Tap More Tools & Options menu

#9. Next, Visual Editor is the option that you must choose in this stage

#10. Finally, the new page or post should now be a duplication of the existing one. 

In fact, this procedure can take some time, and you will have to repeat it for each page or post that you want to copy. Hence, that is why, if you are wanting to duplicate a lot of content, we highly recommend using a duplicate wordpress page plugin.

In conclusion

To sum up, in WordPress, duplicating a page or a post can be beneficial in a variety of ways. In many cases, you might want to make a copy of your current page for future site design inspiration. Not only that, you may need to duplicate an existing post in order to utilize it as a template. Regardless of your purpose, you can take advantage of effective ways we mention above to duplicate a wordpress page or post with ease. Then, do you have any questions on this topic or anything related to the WordPress platform? Let us know and we will solve it for you.

0 comments

Related Posts