Here’s a post on How to Duplicate a Page or Post in WordPress.
You have a WordPress site and want to create a new page or post with the same content as an existing page.
You are not sure how to do that, or if it is even possible. Duplicating posts or pages in WordPress is not very user-friendly.
WORRY NOT…
I will teach you how to duplicate a page in WordPress with just a few clicks with or without a plugin.
You could have your own reasons to duplicate posts from the original post…
and…
I had my own…
I have created custom post types and custom templates and wanted to clone those posts as I required.
This is How I learned to duplicate posts in WordPress and I will walk you through the process step by step and recommend you the easy way.
Table of Contents
- Why Do You Need to Clone or Duplicate a WordPress Page or Post?
- Methods to Duplicate a Page in WordPress?
- Duplicating Page or Post with WordPress Plugin
- Duplicating a Post or Page in WordPress Without a Plugin
- Frequently Asked Questions
- Last Thought
Why Do You Need to Clone or Duplicate a WordPress Page or Post?
As I already mentioned I had my own reasons and you could have your own reasons…
But…
Here are some of the things that can be done by Duplicating a WordPress Page.
- You can duplicate your favorite sales page which is converting.
- You can duplicate an older article (original post) and can extend it to a new article. The best part is you don’t have to start from scratch.
- You can use your custom post templates and you don’t have to design every time.
Ohh…
But…Karan…
Can’t it be done by manually copying and pasting?
I got your question and I had the same doubt…
Definitely, you can manually copy and paste…
But…There is some problem with it.
If you try to duplicate a post by manually copying and pasting. You will not get what you wanted and manually copying will not work.
Meaning…
You will not get your old post settings, featured image, SEO settings, SEO Data, and other metadata (title, meta-description).
And…
The most important.
There are chances that your design will be a big mess.
Methods to Duplicate a Page in WordPress?
There are two ways by which you can clone your posts or pages:
- Cloning Post or Page With a WordPress Plugin (Free Plugin).
- Cloning Posts or Pages Without Plugin.
You can also Duplicate a page via funtions.php Code.
Now…
Let’s see each method step-by-step on how to duplicate a page or post in WordPress.
Duplicating Page or Post with WordPress Plugin
WordPress offers many plugins to create duplicate posts or pages for a website. Duplicating posts and pages are the most popular use, as it allows for building content farms quickly and easily.
These plugins allow you to duplicate content without copying and pasting, eliminating any chance of errors that may be created by manual copy-paste.
Below you can see a list of some WordPress Plugins which will help you to easily clone your post or pages without any hassle.
Using plugins is the safest way as you don’t have to be a techie and you can make all the adjustments from your dashboard itself. The free version will be fine.
# 1 Duplicate Page
This plugin is very useful if you want to Duplicate Custom Posts, Posts, and Pages with a single click. You will have the option to save your cloned posts as public, draft, pending, or private.
How to Install Duplicate Page?
Follow to simple steps below to install Duplicate Page WordPress Plugin:
# Step 1: Install The Plugin.
# Step 2: Activate the plugin.
# Step 3: Customize its settings as needed.
# Step 4: Now Go to All Posts or All Pages as your required.
# Step 5: Find the post or page you want to duplicate.
# Step 6: Click on Duplicate This.
# 2 Yoast Duplicate Post
This plugin is easy to use, the plugin duplicates both the page and post content, as well as the comments. There is an option to add a prefix or suffix to differentiate your original post from cloned one as well. I personally use this plugin.
How to Install Yoast Duplicate Post?
The process is very simple. Follow the steps below to Install Yoast Duplicate Post.
Follow to simple steps below to install Duplicate Page WordPress Plugin:
# Step 1: Install The Plugin.
# Step 2: Activate the plugin.
# Step 3: Customize its settings as needed.
# Step 4: Now Go to All Posts or All Pages as required.
# Step 5: Find the post or page you want to duplicate.
# Step 6: Click on Clone.
# 3 Post Duplicator
Post Duplicator Plugin is a simple page or post cloning plugin. It duplicates any post or page, including custom post types, custom fields, and custom taxonomies. Comments are not carried over to the duplicated post.
How to Install Post Duplicator?
Follow the steps below to Install Post Duplicator:
# Step 1: Install The Plugin.
# Step 2: Activate the plugin.
# Step 3: Customize its settings as needed.
# Step 4: Now Go to All Posts or All Pages as per your requirement.
# Step 5: Find the post or page you want to duplicate.
# Step 6: Click on Duplicate Page or Duplicate Post.
# 4 Duplicate Page and Post
With the duplicate page and post plugin, you can create clones of pages or posts. Pages, posts, and custom posts can be duplicated by a single click, and they are saved as drafts. Duplicate page and post doesn’t come with as many features as other plugins, but it is lightning fast.
How to Install Duplicate Page and Post?
Follow the steps below to Install Post Duplicator:
# Step 1: Install The Plugin.
# Step 2: Activate the plugin.
# Step 3: Customize its settings as needed.
# Step 4: Now Go to All Posts or All Pages as per your requirement.
# Step 5: Find the post or page you want to duplicate.
# Step 6: Click on “Click here to clone”.
Duplicating a Post or Page in WordPress Without a Plugin
I personally don’t advise this method as you need to Enable Duplicating via funtions.php Code or Manually Copy & Paste Code to clone a Page. This method can be a hassle as you need to insert some codes.
If you are comfortable you can follow the below-mentioned methods.
There are two ways through which you can Clone a Post or Page in WordPress Without a Plugin:
- Add Code to Your functions.php File to Duplicate Your Post or Page in WordPress.
- Manually Copy & Paste Code to clone a Page.
Let’s jump into the methods and see how it’s done.
Add Code to Your functions.php File to Duplicate Your Post or Page in WordPress
To manually clone a WordPress post or page, you can edit the code in your functions.php file. It may seem easy to do this, but it is important to make a backup of your website first.
Depending on your needs to enable duplicating for posts you can either use an HTML editor, an FTP client, or the built-in WordPress theme editor.
I will show you how to insert the code through the WordPress theme editor. Follow the steps below to do the same:
# Step 1: Go to your WordPress Dashboard (Backend).
# Step 2: Click on Appearance and then Theme Editor.
# Step 3: Click on functions.php. Paste the below-mentioned code in the editor and click on the update 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( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );
Note: To enable cloning for pages as well, use the same code, replacing the final line as follows:
add_filter('page_row_actions', 'rd_duplicate_post_link', 10, 2);
After that, you update the file. Whenever you hover over a page or post you wish to duplicate, you will see a Duplicate button. You can see the image below:
Manually Copy & Paste Code to clone a Page
You can manually copy and paste the code for the page or post you want to clone if you do not want to edit the functions.php file.
It will take a little time, and you’ll need to copy each post or page individually. If you want to duplicate large amounts of content, we recommend using a plugin.
Follow the steps below to do this:
# Step 1: Go to the page or post you want to duplicate.
# Step 2: Click on the More Tools & Options menu.
# Step 3: Select the code editor.
# Step 4: Copy the code for the page or post.
# Step 5: Go to the New Post or New Page/New Draft.
# Step 6: Open the Code Editor in the new post or page.
# Step 7: Paste in the code (copied content).
# Step 8: Select More Tools & Options.
# Step 9: Select Visual Editor.
# Step 10: Now the new page or post should be a clone of the old one.
Frequently Asked Questions
What are the Best WordPress Plugins to Duplicate a Page?
The Best WordPress Plugins to Duplicate a Page are:
# 1 Duplicate Page.
# 2 Yoast Duplicate Post.
# 3 Post Duplicator.
# 4 Duplicate Page and Post.
How to Duplicate a WordPress Post or Page With a Single Click?
I have explained two methods in this post. You can do that via a WordPress Pugin or via functions.php. Step by step process is in the post.
Last Thought
I personally liked the WordPress Plugin Method. Duplicating a WordPress Post or Page via functions.php is also fine if you don’t want to add a plugin. These are the easiest way.
If you are into blogging then just take a look at Blogging Mindset Post. If you are planning to Start a Blog and Make Money Online Then Read This.