Technology

How To Duplicate A Page In WordPress?

How To Duplicate A Page In WordPress

Do you want to clone your WordPress page and make a new copy of it? It might be important to do so because this will help you make a new copy of it and edit it to create a modified copy of the page.

Therefore, if you wish to learn how to duplicate a page in WordPress, then you are at the right place. Continue reading to find out the various ways of doing so. You will learn how to do so by using plugins and also without them.

How To Duplicate A Page In WordPress With Plugins?

How To Duplicate A Page In WordPress With Plugins

If you want to learn how to duplicate a page in WordPress, then you can do so by using any of these four methods explained below:

1. Duplicate Post

One of the most popular plugins available for page duplication in WordPress is Duplicate Post. It has features like entire cloning pages on WordPress, which also includes cloning comments and replies posted on it as well.

To do so, you need to follow the steps below:

  1. Search for and install the Duplicate Post plugin WordPress plugin
  2. Open your WordPress dashboard
  3. Go to the Posts option
  4. If you want to clone pages, then click on the Posts > All option
  5. Open and explore the page or post you want to clone
  6. Click on the Clone option on top (it only appears if you installed the plugin). This will clone only one page at a time
  7. If you wish to clone multiple posts in WordPress, then select all the posts and click on the Bulk Actions option

2. Duplicate Page And Post

Even though it has less features than its peers, Duplicate Page and Post get the job done. It makes up for fewer features by ramping up the speed of cloning pages on WordPress. 

To use this plugin, you need to:

  1. Search for and install the Duplicate Page and Post WordPress plugin
  2. Open your WordPress Dashboard
  3. Go to the Posts option
  4. Click on Posts > All or Pages > All, depending on whether you want to duplicate posts or pages, respectively
  5. Finally, click on the Duplicate option that appears on top (it won’t appear if the plugin is not installed)

3. Duplicate Page

If you want a plugin that has lots of extra features for better usability, then you can consider using the Duplicate Page WordPress plugin. Apart from pages and posts, you will also be able to clone various types of custom posts as well.

One of the best features of this wordpress plugin is that you can save the cloned copies of your pages and posts as drafts or pending copies. You can also make them private or public, as per your requirements.

To make use of this plugin, you need to:

  1. Search, Install, and Activate the Duplicate Page WordPress plugin
  2. Now, you need to configure its settings which will automatically appear when you activate this plugin
  3. Open the Pages or Posts option from the sidebar and click on All
  4. Click on the Duplicate option that will appear on top of the page or post you wish to duplicate from the list

4. Post-Duplicator

If you want a quick and easy-to-use method on how to duplicate a web page in WordPress, then you can use the Post Duplicator plugin. This one has the capability to create exact clones of the pages, and posts, along with any customizations and taxonomies that might appear on them. 

To use this WordPress plugin, you need to:

  1. Search, Install, and Activate the Post Duplicator wordPress Plugin
  2. Open your WordPress Dashboard
  3. Go to Pages or Posts and click on All Then, hover your mouse cursor over the page or post you wish to duplicate
  4. Finally, click on the Duplicate Post or Duplicate Page option.

How To Duplicate A Page In WordPress Without Plugins?

How To Duplicate A Page In WordPress Without Plugins

If you want to learn how to duplicate a page in wordPress without plugins, then you can do so too. You can do this by following the two methods explained below:

1. Duplicate Via Functions.php File

If you want to have total control of the duplication process of your WordPress pages, then many will say that the best way to do so is by editing the functions.php file. This file contains various codes that you can customize and configure to your will.

However, before you decide to change the codes of the functions.php file, ensure that you have created a backup of the file beforehand. To duplicate a WordPress page by editing the functions.php file, you need to follow these steps below:

  1. Open the functions.php file by searching it on My Computer
  2. Edit it using the application Secure File Transfer Protocol (FTP)
  3. Copy these lines of code from below and paste it on the file
/*
 * 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('page_row_actions', 'rd_duplicate_post_link', 10, 2);

2. Copy And Paste Codes Manually

If you do not want to edit your Functions.php file, then you can manually clone your WordPress page by:

  1. Open the page that you wish to duplicate from the Posts > All section
  2. Then, click on the option More Tools & Options
  3. Click on Code Editor
  4. A page that shows the codes of the page will open up. Copy it whole
  5. Then, click on the option that says New Page
  6. When the new page opens, open its Code Editor
  7. Paste the code that you copied previously
  8. Open the More Tools & Options menu
  9. Click on Visual Editor
  10. Save the post

FAQs (Frequently Asked Questions):

Some frequently asked questions by WordPress users are:

Q1. What Happens When You Duplicate A Page On WordPress?

Ans: When you duplicate a page in WordPress, you will have two saved copies or drafts of the same post. This is a useful feature since you can then publish a modified article and still keep the original as a backup.

Q2. Why Would I Want To Duplicate A Page On WordPress?

Ans: It is important to learn how to duplicate a page in WordPress because doing so will help you create copies of the posts. Then, you can use these copies and create a new page and add modified content to it to brand it as a new page.

Q3. How Do I Duplicate A Page In WordPress Elementor?

Ans: If you want to learn how to duplicate a page in WordPress Elementor, then you need to:
⦿ Open the post and edit it using the Block Editor
⦿ You will find an option on the sidebar menus that says Duplicate

Conclusion

Learning how to duplicate a page in WordPress is a pretty neat trick to learn. This is because in your professional career as publisher, you might have to copy and duplicate older posts sometimes. This is done to make a modified copy of the posts.

Therefore, learning how to do so is essential as it helps you save a lot of time and effort. To do so, you can either take the help of using various WordPress plugins. There are also two other ways to do it without Plugins, with one of them being by editing the functions.php file.

Read Also:

Debamalya Mukherjee
Debamalya is a professional content writer from Kolkata, India. Constantly improving himself in this industry for more than three years, he has amassed immense knowledge regarding his niches of writing tech and gaming articles. He loves spending time with his cats, along with playing every new PC action game as soon as possible.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *