Do you want to know how to duplicate a page in WordPress? Cloning and duplicating a page or post in WordPress with or without plugins is not a hard task but you still need to understand how to do it. We have easy and quick ways of duplicating a page or post in WordPress.
Before jumping on to the process of duplicating a page or post, let’s understand what duplication means. If you think that it is just copying and pasting the information then you are mistaken because there is a lot more to do. Duplication can help you reduce the amount of unnecessary work that is required to organize content on your WordPress. Furthermore, it also saves time by retaining the SEO data, page template, and graphics when redesigning or updating your website. Fortunately, duplicating posts or pages and all of their associated data are simple in WordPress. If you are eager to know how to delete categories in WordPress then our user guide on this topic should be your next read.
We will mainly highlight how these simple ways will help you complete the task of cloning your page or post. This article will discuss how to clone a Post or Page safely and how various plugins can help duplicate the Posts or Pages. These are two primary ways of duplicating a page or post in WordPress:
- Duplicate Pages or Post With Plugin
- Duplicate Pages or Post Without Plugin
How to Duplicate a Page in WordPress through plugins
When you use a plugin, cloning a page in WordPress is easy because everything is done directly in your Dashboard. Although you won’t be editing your site’s code directly, plugins are the safest option to duplicate a post or Page. If you’re looking for the right tool, here are four plugins worth checking out.
- Duplicate Page and Post
- Duplicate Post
- Post-Duplicator
- Duplicate Post Page Menu & Custom Post Type
Duplicate Page and Post
Duplicate Page and Post limitations in functionality but more than makes up for it in speed. This small Plugin is one of the quickest ways to duplicate a Post or Page in WordPress, and it won’t load up your site with unneeded functionality. Duplicate page and post plugins allow you to make clones of your pages or posts. With a couple of clicks, you may clone posts, pages, and custom posts, which will be saved as a draft. Duplicate Page and Post are missing many of the functionality of other plugins; however, it is speedy compared to others. Use the methods below to clone a Page or Post using this Plugin:
- Login to your WordPress admin panel to access the Dashboard, navigate the Plugin section, and click on the Add New button.
- Search Duplicate Page and Post in the search bar and then Install and Activate the Plugin.
- Navigate to Post or Page and Click on All posts or Page depending on what you want to duplicate.
- Next, you need to hover over the Post or Page you want to clone, as shown below.
- Then, Click on the Duplicate Option
Duplicate Post
Duplicate Post is a popular method for replicating WordPress pages and posts. This Plugin is simple to use and replicates everything from the page or post content to the comments. It also allows you to add a prefix or suffix to distinguish your original Post from the Clone. If you want to use this tool to duplicate a post, do the following:
- First login to the WordPress admin panel and then go to the Plugin> Add New.
- Search for the Plugin, Install and Activate the Plugin.
- Now return to your Dashboard, navigate the Posts or Pages you want to replicate, and click on Clone to duplicate it.
- If you want to duplicate all the Pages or Posts, you have to select the multiple Posts or Pages and Clone them all at once using the Bulk Action.
- Return to the Dashboard and check the Pages or Posts you have cloned.
Duplicate Page
Duplicate Page comes with a few unique functionalities that other cloning plugins don’t have. We’ll show you how to duplicate the Page, Post, and make a custom post type. Plus, you can preserve the resulting duplicates as pending, drafts, public, or private. This Plugin will efficiently and quickly make copies of the Posts and Pages. Just hover over a post in the edit screen and select ‘Duplicate {post_type}’ to create a duplicate post.
- You need to use the Duplicate Page plugin; for that purpose, log in to your WordPress admin panel to access the Dashboard.
- Go to Plugins and Search for Duplicate Page and Click on Install and activate the Plugin.
- Navigate to the Settings and configure its settings that meet your needs. (i.e. Duplicate Post Status: Private, Draft or publish and Choose Editor: classic or custom)
- Once the settings are complete, go to the Pages or Post you want to replicate and click on the Duplicate This button.
- Return to the main page and see the newly duplicated Page or Post.
Duplicate Post Page Menu & Custom Post Type
It is another plugin that custom clones your Pages and Posts. So in a single click, you can create multiple pages, posts, menus, and custom posts such as tickets, products, coupons, events, etc. This Plugin will release the burden of creating numerous mock Posts or Pages on your site to review the website layout. It’s responsive and efficient to use and wouldn’t add much load to your website. To duplicate the Pages Or Post or any content you need, follow these steps:
- Login to your WordPress admin panel to access the admin dashboard, and then go to the Plugin and click on Add new button.
- Search for the Duplicate Post, Page, or Menu plugin, click on Install and Activate the Plugin when the search result appears.
- Now, navigate to the Pages and Posts you want to duplicate and enter the number(How many times you want to replicate these Pages or Posts).
- Once you enter the number, click on the Duplicate button, return to the main page, and see the duplicated Pages Or Post.
How to Duplicate a Page in WordPress without a Plugin
If you don’t want to install any plugin, of course, there is a way you can duplicate the content without using any plugin. We will show you how to Duplicate a Page in WordPress without Plugin. This method also has two procedures:
- Enable Cloning through funtions.php code
- Manually Copy & Paste Code to Duplicate a Page
Before making any changes in the code, you need to Backup your entire site just for safety purposes. If you didn’t place your code in the correct position or any other issues appear while editing code, you have a backup that will restore your website.
Enable Cloning through funtions.php code
Editing the code in your functions.php file is one of the manual ways to clone a WordPress Page or Post. While this seems easy, you should proceed with caution and create a backup of your website first. You’ll have to access your functions.php file and open it for editing through Secure File Transfer Protocol (FTP) or whatever method you would like to activate cloning for posts. But first, we will show you a simple way to find the functions.php.
- Now you have to log in to your WordPress admin panel and then hover over the Appearance.
- There are some options related to your theme, and you need to click on the theme Editor button.
- Once a new screen appears, there is a list of .php files on the right-hand side, and you need to find the functions.php file.
- After finding the file, you’ll need to past the following code fragment to the end of 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 the 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 );
If you want to duplicate the Pages, then use this same code to allow cloning for pages as well, but replace the final line with:
add_filter( 'page_row_actions', 'rd_duplicate_post_link', 10, 2 );
After pasting the code, you need to click on the Update File to save and re-upload to your server. Once the file is updated, then you can return it to your admin dashboard. Next, go to the Page or Post that you want to clone to see the Duplicate button.
Select any Post or Page and simply click on the Duplicate button; your selected page is successfully cloned.
Manually Copy & Paste Code to Duplicate a Page
You can manually copy and paste the code for the Page or Post you want to clone if you don’t want to edit your functions.php file. You’ll need to do the following to accomplish this:
- You have to log in to the WordPress admin dashboard and then navigate to the Page or Post you want to duplicate.
- Open the desired Post and click on the Options menu or More tools.
- In the options menu, there are several options click on the Code Editor.
- Once it’s opened, then copy the code for Post or Page.
- You have to create a new Page or Post, open its Code Editor, and paste the code here.
- Next, go to the More options and click on Visual Editor.
In the Visual Editor, you will see the same layout and context; this method should clone your Page or Post. However, this procedure can take some time, and you’ll have to repeat it for each Page or Post you want to duplicate. However, with page cloning, streamlining your WordPress experience is simple. That’s why, if you’re looking to replicate a lot of content, we recommend you use a plugin or functions.php method.
We do have an article on changing the author in WordPress, so no need to panic if you wish to change the name of the author after your writer has left the organization.