How to Duplicate a Page in WordPress

How to Duplicate a Page in WordPress

From time to time, you will find yourself in a situation where you will want to duplicate a page in WordPress for one reason or another and today, we are going to talk a little bit about how to do it right.

If you decide to simply copy and paste the page, that will do it, but it will not move the SEO optimization, page templates, featured images and other associated data. With that in mind, there is a better way to duplicate a page in WordPress, especially if you want to clone an existing page to do a few changes in one of the copies and compare it with the previous version.

So how to duplicate a page in WordPress?

WordPress duplicate page actually takes nothing more than a single click. So let’s go over this quick tutorial and help you find the right WordPress duplicate page plugin!

Table of Contents:

Duplicate With Plugins

There are thousands of useful WordPress plugins that will save you a lot of time and effort, like wpDataTables.  Some plugins can help you duplicate a page in WordPress. Some of them are paid for, some of them are free, but if you compare them, you will surely be able to find the right WordPress clone plugin for you.

Plugin Search

So how to duplicate a page in WordPress with a plugin? Well, first you have to find the plugin of your choice. Click on Plugins > Add New in the admin area, find the desired plugin, and choose Install Now.

WordPress will then automatically download and install the plugin and you will be all set to start using it. Keep in mind though that this potion is only working with free plugins.

The Upload Method

If you want to use a paid plugin, the upload method is what you will have to do to add the plugin of your choice to WordPress.

First, you will have to download the plugin from the source, then go to WordPress, click on Plugins > Add New. You will see the Upload Plugin option on top of the page. Once you choose this option, you will have to find the downloaded file and install it.

Another method of installing plugins using an FTP client, but that is the least beginner-friendly option.

WordPress copy page is easy with the use of the right plugin, so let’s take a look at some of them and the way they work to help you choose.

Duplicate page plugins

Duplicate Page

Duplicate Page is a great plugin if you want to WordPress duplicate post. You can duplicate your pages, posts and custom post by just one click and it will save as your selected options (draft, private, public, pending).

All you have to do to duplicate WordPress page with this plugin are these 4 simple steps:

  1. First Activate Plugin.
  2. Go Select to Duplicate Page settings Menu from Settings Tab and savings settings.
  3. Then Create New Post/Page Or Use old.
  4. After clicking on duplicate this link, then duplicate post/ page will be created and saved as draft, publish, pending, private depending upon settings.

Duplicate Post Plugin

The Duplicate Post Plugin allows you to duplicate pages in WordPress while also providing you with a number of useful customization options. There is also an option of adding a pre-set suffix or prefix to the title of your cloned page or post.

How to duplicate page in WordPress with this plugin? Just follow these 4 simple steps:

  1. Install and activate the Duplicate Post Plugin.
  2. Click on Pages > All Pages
  3. Find the post you want to clone and you will find two options: Clone and New Draft.
  4. If you want to WordPress clone page, click on the Clone option. However, if you want duplicate pages WordPress and start making further changes immediately, click on New Draft. Post editing, you can choose to Save Draft or Publish.

This Plugin also offers a number of options for copying not only content but also dates, status, attachments and more.

Post Duplicator Plugin

Post Duplicator Plugin will allow you to duplicate page in WordPress by cloning an exact replica of the original page or post while retaining the custom fields at the same time. To copy a page in WordPress with this plugin, follow these simple steps:

  1. Install and activate the Post Duplicator Plugin.
  2. Choose the page or post you want to duplicate and click on Duplicate Page/Duplicate Post.
  3. You will get a cloned copy of your page or post with the default suffix Copy at the end of its title.

Duplicating without Plugins

You can WordPress duplicate page without a plugin, but keep in mind that before doing so, you should create a backup of your website and all its data.

However, to duplicate WordPress pages without plugins, you will have to use coding. If you are a developer, the process will be fairly easy. However, if you are an absolute beginner, you should probably consider finding a plugin to do the heavy lifting for you.

Add this code:

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


/*
* Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
*/
function wpdt_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’, ‘wpdt_duplicate_post_as_draft’ );

/*
* Add the duplicate link to action list for post_row_actions
*/
function wpdt_duplicate_post_link( $actions, $post ) {
if (current_user_can(‘edit_posts’)) {
$actions[‘duplicate’] = ‘Duplicate‘;
}
return $actions;
}

add_filter( ‘post_row_actions’, ‘wpdt_duplicate_post_link’, 10, 2 );

Once complete, you will see a Duplicate option in the All Pages or All Posts section.

By editing WordPress functions.php file, you can add the code snippet to your currently active theme. Find the Appearance tab on the left-hand side of WordPress dashboard and click on Editor. On Editor page, choose the functions.php file from right-hand side list of files.

Duplicate a Page in WordPress using FTP

If you want to keep your theme’s functions file tidy, you should paste above code snippet in a separate file and then call it in your functions.php file like in the example below:

require get_template_directory() . '/inc/duplicate-post.php';

inc is a folder inside your theme folder, and the file containing above code snippet called duplicate-post.php.

Upload all files you have changed using an FTP Client to your WordPress installation.

Once you have done that, you can go to Posts on your WordPress dashboard (Posts -> All Posts), find the post you want to copy, and choose the Duplicate option underneath the Post title.

Ending thoughts on how to duplicate a page in WordPress

There are many reasons why a person would want to duplicate a WordPress page and there are several ways to do it. So how to duplicate a page in WordPress? The easiest option is to find the right plugin to duplicate post WordPress quickly and easily.

You can also play around with some coding and clone a WordPress site without plugins. The third option is duplicating pages in WordPress using FTP. All options are effective so it all boils down to your personal preference and skill levels.

If you enjoyed reading this article about how to duplicate a page in WordPress, you should also read these:

Up Next:

How to Delete a WordPress Blog

How to Delete a WordPress Blog