How to Duplicate A Page in WordPress? (Step By Step)

Creating a WordPress duplicate page is quite different from the conventional method of copying and pasting content. There are a lot more things you need to take care of while creating a WordPress duplicate page, that you will be going to see in this detailed post.

Creating duplicate pages in WordPress can save a lot of your time and effort in redesigning the website as well as making some changes in the content or using the same layout to duplicate different pages of your website. Whatever the reason is, there are multiple ways through which you can easily duplicate WordPress pages for your website.

In this tutorial, we will let you know How to duplicate a page in WordPress with the different options available i.e. without or without the use of plugins, and also without affecting your website metrics.



What is the Meaning of WordPress Duplicate Pages And Why Do You Need to Have Them?

WordPress’s duplicate page is exactly what its name seems. It is a copy or replica of the original page, which you can either edit or update without affecting the original one.

When you consider creating a WordPress duplicate page of your website, there are mainly two motives behind this that make more sense than creating a completely new page for your website.

1. Updating the Content

If the layout of the page remains the same and all you need to update the content, creating a WordPress duplicate page is a way more worthy option than creating a completely new page. It just not reduces the effort to duplicate a page but also saves a lot of time and other resources.

Let us understand it with an example, suppose you have to create a landing page for your website, but it should maintain the same layout and must have the same content as the homepage. In this case, creating a replica or duplicate page of your homepage and making some changes to it, makes more sense rather than creating a completely new page.

This way you can save your precious time as well as reduce extensive efforts.

2. For Staging or Experimenting Purpose

If you are not satisfied with the design of the current page and you want to make edits or certain changes to it. In this case, you would be unsure what the final page would look like, and at the same time, you do not want to lose the structure of your current version.

Especially, if you compare both the designs and decided the older one is way better, the duplicate pages will let you do a lot of experiments and you can play with all the creativity and options available without risking the design of the original page. You can also delete the duplicate page without fearing losing the original page content.

Now let us see how you can duplicate a WordPress page with or without plugins.


Read: 🚩 How to enable Website Copy Protection in 2023?


How to Duplicate a WordPress Page With Plugins?

WordPress is best known for its high customizability and flexibility. There is always a WordPress Plugin available for almost anything on WordPress. Similarly, if you wish to duplicate a page on WordPress, you can use the help plugins available on the WordPress repository as well as third-party plugin directories.

Since the majority of WordPress users are beginners and do not like to buy premium plugins, for them we have listed some of the best free WordPress duplicate page plugins you can try.

1. Yoast Duplicate Post

how to duplicate a page in wordpress
Yoast WordPress duplicate post plugin

One of the most accessible and user-friendly plugins that help you to duplicate pages in just simple steps. All you need to do is to first install the Yoast Duplicate post WordPress plugin from the WordPress repository.

Go to your WordPress dashboard > Plugins > Add new and search for “Yoast Duplicate Post“. Once you find the plugin click on the install button followed by clicking on activate and you are done.

how to clone a wordpress page
Installing the Yoast Duplicate Post plugin

After successfully installing and activating the plugin, go to your posts section and click on All posts as shown in the picture below. You will find two links clone and the New Draft option just beneath the title of the post.

How to Duplicate a WordPress Page With Plugins
Creating WordPress Duplicate posts

Now when you click on the Clone link, it will duplicate a copy of the post and you won’t be able to open it in the post editor. However, if you chose to click on the New Draft link, it will have a WordPress duplicate post right away and you will be able to open the duplicate version in the post editor.

Similarly, you will also find the same links below the title of the page as shown in the picture below:

how to duplicate a wordpress page
Creating WordPress Duplicate posts

How to Duplicate a Page in WordPress without Plugins?

In case, if you do not wish to use any WordPress plugin to duplicate pages, the best alternate option is to go by manual methods. In this method, you can either add some codes to the function.php file or manually copy and paste the code of the page.

Now let us see how you can proceed.

1. How to duplicate A WordPress page or post by function.php File?

The first manual method you can try to duplicate a page or post in WordPress is editing your function.php file. But before handling or making any changes in your WordPress files, make sure you have created a complete backup of your website first.

Now to access your function.php file, you can use FTP (file transfer protocol) client such as FileZilla or through cPanel (if provided). Once you can get access through all the files, go to your function.php file and open it in the editor. Now, all you need to do is to add the given code below in the file save it and upload it again.

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

Now the above snippet will only let you duplicate WordPress posts. But for replicating WordPress pages, you have to replace the last line of the above code with the snippet given below:

add_filter('page_row_actions', 'rd_duplicate_post_link', 10, 2);

When you are successfully able to add the given snippet to the function.php file, your posts and pages menu will have a Duplicate button option.

2. How to Manually Duplicate A Page in WordPress?

If you do not want to make any changes or edit your config.php file, the best thing you can do alternatively is to copy and paste the code of the page or post you want to replicate. To do this, all you need to do is

Step 1: Open the page or post you want to duplicate (in the block editor).

Step 2: Click on the three dots located at the top right corner of the page as shown in the picture below.

WordPress duplicate page
WordPress duplicate page

Step 3: Click on the Code editor and copy all the code for the page or post.

Step 4: Now, click on Add new page or post.

Step 5: Open the new page or post in the block editor and similarly click on the code editor, just like you did in step 2, and paste the code that you have copied.

Step 6: Now you can turn into a visual editor and you will find the post or page has been successfully cloned.

Although, this method would seem to be time taking, and for each post or page you have to manually copy and paste the codes. Hence, we highly recommend you take the help of WordPress duplicate page plugins that can do the same job in just a few seconds.

Now you have learned different methods to duplicate posts and pages, what about removing or deleting them? Let us find out.


Read: 🚩 How To Setup WordPress Redirect Plugins


How to Delete or Remove WordPress Duplicate Pages or Posts?

After successfully creating duplicate pages and posts, if you are looking to delete or remove them, the whole process is quite easy and simple.

First, you need to go to your pages or posts from the WordPress dashboard and select the duplicate pages or posts.

You will find multiple links or options such as “Edit“, “Quick Edit” and “Trash“. To delete or remove a duplicate page or post you have to click on the Trash link. But, your duplicate post/page has not been permanently removed. It has been moved to the Trash bin where you can still access the page or post.

Delete or remove WordPress duplicate page or post
Delete or remove WordPress duplicate page or post

To remove or delete it permanently from your WordPress, you need to navigate through the trash folder and select the “Delete permanently” option from the drop-down many Bulk actions and check the relevant pages or posts you want to delete as shown below:

Delete permanently WordPress duplicate page or post
Delete permanently WordPress duplicate page or post

Click on the Apply button and you are done. You have successfully been able to delete a WordPress duplicate page or post from your website. Even though, if you have accidentally deleted the clone or duplicate copy of a page or post, you can still make a new one anytime.


Summary

From the above post, you must have noticed that using a WordPress duplicate page plugin is way easier to use and quicker method than the manual. You do not have to take the risk of editing PHP files and it does not take that much effort and time.

However, for single pages or posts the manual method can be a great option but for multiple pages or posts using a plugin would be a great option. You can use either plugin that we have mentioned in this post or you can choose any other from plenty of other options available offering various features and functionalities.

If you choose to go this way, you will surely save a lot of time and effort as well as reduce the risk of any error while doing it manually.

In case you know of any other method which seems more economical and better than what we have mentioned in this post, please do let us know in the comment section below.


Frequently Asked Questions

Can you duplicate the page in WordPress?

Yes, you can easily duplicate pages or posts in WordPress with the help of WordPress duplicate page plugins. However, you can also do it manually by editing your function.php file.

How do I duplicate a page in WordPress without plugins?

You can duplicate pages in WordPress without plugins by the following two methods:
1. By editing your function.php file
2. By copying and pasting the code of the page or the post you want to duplicate or make a clone of.

Is cloning a website illegal?

Cloning a website is completely illegal as long as you do not have the author’s permission or Copyright of the main site.


Leave a Reply

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