How to duplicate a page or post in WordPress?

Do you need to create a copy of a page on your WordPress site? Maybe you want to make some changes to the original page, or just test out a new design. Whatever the reason, duplicating a page is easy to do. In this article, we will show you how to duplicate a page in WordPress.

How to Clone a Page in WordPress?

Cloning a page on WordPress is very easy. With plugins, it can be done in just a few minutes. If you are looking for the best plugins to help you, here are four that are worth checking out.

Yoast Duplicate Post

-Duplicate Post

One of the most popular plugins for duplicating pages or posts is Duplicate Post. It is easy to use and helps you clone a page in just a few clicks. You will do that in a few steps. They include;

  • Install and activate the plugin.
  • On the WordPress dashboard, Proceed to the posts, then Pages, and then All.
  • Navigate to the page that you want to clone then click on Clone under the Duplicate Post section.
  • You will be given two options; one is to create a new draft, and another is to publish immediately. Choose your preferred option then click on OK.
  • Multiple posts or pages will be selected. Go to the options that say clone using bulk actions.

Duplicate Page and Post

-Duplicate Page and Post

This plugin does not have a lot of features. However, it duplicates pages very quickly. It is the fastest way to clone a page on WordPress. The steps are;

  • Install and activate the plugin.
  • Proceed to Posts > All or Pages > All. This will depend on the exact posts you would like to duplicate.
  • Proceed to posts or pages and locate the page you want to duplicate.
  • Click on Duplicate this post or Duplicate this page.

Duplicate Page

-Duplicate Page

This is another plugin that is easy to use. With this plugin, you can duplicate pages and posts with ease. The steps include;

  • Install and activate the plugin then Proceed to Pages¬† >¬† All Pages.
  • Configure the settings to align well with exactly what you need to do.
  • Proceed to pages > Posts or All > All to find the specific content you want to clone or duplicate.
  • Hit the option that says duplicate this option

Post Duplicator

-Post Duplicator

Post Duplicator is another plugin that is popular for cloning pages and posts. It helps you duplicate a post or page with just one click. The steps are;

  • Install and activate the plugin then Proceed to Posts > Add New Post.
  • Look for the post you want to clone using the search bar or navigate through your categories/tags.
  • Click on the Duplicate button found just below the post editor.
  • You will be given two options; one is to create a new draft, and another is to publish immediately. Choose your preferred option then click on OK.

How to duplicate a page without a plugin?

In case you do not have plugins, you can still clone a page on WordPress. You can either do that manually or use other editing icons such as funtions.php or by simply coding the specific code. We will discuss how each of these methods works.

-Enable Cloning through the code funtions.php

/*
 * 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 );

This is another method of cloning a page on WordPress. You can do that by manually editing that code. This is not a complicated process. However, you should make a backup for your website first.

For this process to work, you will be required to access the functions.php files and then proceed to open them up for editing purposes. You can do that using the FTP (Secure file transfer protocol). Then there is a specific code you will have to add at the end of the file.

Once you have done that, save the file and re-upload it to your website. You can now navigate to the page you want to clone, and it will be automatically duplicated for you.

-Manually Copy & Paste Code to Duplicate a Page

The other method you can use to clone a page on WordPress without a plugin is by manually copying and pasting the code. This process is a little more complicated than the first one. However, it does not require you to access your website’s files or use FTP.

The steps are;

  • Open the post or page you would like to duplicate.
  • Click on the Text tab which is located next to the Visual tab.
  • Highlight and copy all the code.
  • Create a new post or page then click on the Text tab again.
  • Paste the code you had copied earlier then click on Publish/Update.
  • You have now successfully duplicated a page on WordPress without using a plugin.

As you can see, there are quite a few methods you can use to clone a page on WordPress. Choose the one that works best for you and your website.

Conclusion

Now that you know how to duplicate a page in WordPress, you can create as many clones as you need. This comes in handy when you want to create multiple versions of a page or post. It is also a useful tool for creating landing pages and testing different design elements on your website. So go ahead and start duplicating.

Add a Comment