-
Home / WordPress / How to do WordPress Duplicate Page Both Manually and Using a Plugin
WordPress Duplicate Page

How to do WordPress Duplicate Page Both Manually and Using a Plugin

Moreover, for a variety of reasons, you might need to replicate a post or page when using WordPress. Understanding how to do WordPress duplicate page information across numerous pages can help you operate more efficiently, whether it’s for rapid content updates or keeping a particular layout for new pages.

However, this course will go over both manual and plugin-based methods for quickly and effectively creating a new page or post from pre-existing material.

Further, to guarantee a seamless process, we will also walk through a few circumstances where this approach is useful and offer advice on how to duplicate a WordPress page. Now let’s get going.

  1. How to Use a WordPress Plugin to Copy Pages or Posts
  2. How to Manually Copy Pages or Posts
  3. Why Would You Copy a WordPress Post or Page?
  4. How to Copy Pages from the WordPress FAQ
  5. Conclusion

How to Use a WordPress Plugin to Copy Pages or Posts

However, it is possible to manually copy and paste your WordPress page or post. Although there is a Copy-all-blocks feature in the block editor, it is not very useful for copying pages and posts.

wordpress-gutenberg-copyallblocks

Only the text content of a post or page is duplicated when it is copied by hand. However, sections of the template, graphics, and SEO components like title tags and meta descriptions must be copied separately. When cloning numerous WordPress posts, pages, or custom post types, the procedure is laborious.

However, If you use a duplicate post plugin, you may stay away from this problem. This technology reduces human mistakes and streamlines the duplication process.

Using Duplicate Page, you can replicate a post in WordPress as follows:

  1. Duplicate Page can be installed and enabled from the WordPress plugin directory. You can also manually upload the plugin files through your admin dashboard or use an FTP client to install the plugin.

duplicate-plugin-installation

2. Further, to customize the plugin’s settings, navigate to Settings → Duplicate Page. moreover, we provide it in both Gutenberg and the traditional editor for this tutorial. Once all duplicate content has been assigned a Draft status, the plugin takes care of it and sends you back to the post list.

duplicate-page-plugin-configuration

3. From your WordPress dashboard, navigate to Posts → All Posts. You will see a Duplicate This button beneath each post. When you click on it, a fresh draft of the exact copy of the post of your choice is created.

Moreover, as a freemium plugin, Duplicate Page has premium features that can only be unlocked by upgrading to Pro. Also, you can alter the placement of the duplicate page, establish a default prefix and suffix for your duplicated page entries, and restrict plugin access based on user responsibilities by purchasing a license for $15/website.

If Duplicate Page isn’t what you require, take a look at these other well-liked plugins:

  • Yoast Copying Content: Yoast Duplicate Post, created by the same team that created the well-known SEO plugin, also it allows you to duplicate many items by utilizing the Bulk Actions functionality.
  • Following the duplicator: This plugin is perfect for WordPress sites of all sizes and niches because it allows custom post types in addition to custom taxonomies and fields.
  • PP duplicate: You can replicate content from the front-end single post view or the back-end admin dashboard using this plugin.
  • A duplicate post: This WordPress duplication plugin can detect and delete duplicate material with just a few clicks, in addition to copying posts.

How to Manually Copy Pages or Posts

However, in addition to using plugins, you can edit the functions.php file to enable a duplicate link in your Pages and Posts sections. This file is located in the wp-includes core folder on your WordPress website.

The functions.php file can be edited using one of four methods: the built-in WordPress editor, an HTML code editor, an FTP client like FileZilla, or the File Manager on your web server.

However, establishing an FTP account and connecting it to the server are steps in the FTP client approach. Since FileZilla is a widely used FTP client and is somewhat user-friendly, we advise establishing an FTP connection.

Also, in the meantime, you can use the built-in WordPress editor from your WordPress dashboard by going to Appearance → Theme File Editor.

However, the easiest way might be to use an HTML editor if you know how to code. Also, spell-checking and error-detection tools are typically included in code editors, guaranteeing clear and functional code.

Important: Before making any changes to WordPress files, make a full backup of your website to prevent data loss.

Further, to begin, go to Files → File Manager in your Control Panel and launch the file management application. To gain exclusive access to the resources on your WordPress website, choose Access Files of your domain name.

Then, look for the functions.php file in the wp-includes → public_html folder. Double-click the file to edit it, or right-click to choose Edit.

At the bottom of your functions.php file, paste the following code fragment:

Plain text

Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/*
* Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
*/
functionrd_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
*/
functionrd_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);
/* * 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 );

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

Also, a duplicate link is added to the Posts section by the custom code shown above. If all goes according to plan, each post should have the link underneath it. To duplicate the entry as a new draft, click Duplicate.

All that’s needed to add the Duplicate feature to your Pages section is to swap out the last line of the code above with this snippet:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
add_filter(‘page_row_actions’, ‘rd_duplicate_post_link’, 10, 2);

In a similar vein, you may create a new draft of a WordPress page by clicking the link.

Why Would You Copy a WordPress Post or Page?

Here are a few typical justifications for creating a WordPress page duplicate:

  • A/B experimentation: You may rapidly make small adjustments by duplicating the original page rather than starting from scratch every time.
  • Simplifying the process of design: Duplicating helps you avoid having to recreate pages again while creating a new website. Also, the Yoast Duplicate Post plugin is one such tool that makes the procedure even simpler.
  • Maintaining uniformity in page layout optimization: The formatting, style, and layout of an existing page are guaranteed to stay consistent when it is duplicated. However, eliminating design differences is very useful when dealing with a custom page template.
  • Constructing a setting for staging: As an alternative to setting up a staging site, you can make a duplicate post or page to test out content, albeit this is not advised for comprehensive website testing and development.
  • Producing material in multiple languages: Cloning pages offer a translation starting point if your website has multilingual content. Also, it is possible to translate the text into multiple languages without changing the original layout and style.

Moreover, having numerous identical pages on your website is not a smart strategy for WordPress SEO, even though duplicating a page or post can be advantageous. Search engines will select the earliest published URL as the canonical version and crawl the copies less frequently when numerous URLs point to the same piece of content.

However, by giving pages you want search engines to rank canonical tags, you can combine duplicate URLs. Fortunately, most SEO plugins come with the ability to configure canonical URLs.

To save time on consolidating duplicate material, you can duplicate posts and pages for A/B testing and then move the ones you want to preserve to the live site.

How to Copy Pages from the WordPress FAQ

The most common queries regarding WordPress page duplication are answered in this section.

Is it Possible to Copy a WordPress Post or Page?

Indeed. You have three options: add custom code to the site’s functions.php file, utilize a WordPress duplicate page plugin, or manually copy the text of the page. Further, select the approach based on your technical proficiency and demands.

Why Would I Want to Copy a WordPress Page or Post?

Moreover, duplicating a WordPress page or post facilitates A/B testing, speeds up the process of creating a website, and aids in keeping page layouts constant throughout the site. Translations and improvised staging options can also be initiated from duplicate content.

Does WordPress Page or Post Duplication Affect SEO?

Because duplicate URLs might cause problems for SEO, it is not advisable to duplicate pages or articles. Moreover, search engines crawl copies less frequently and prefer the original page as canonical. To give particular pages priority, use SEO plugins to set canonical tags. However, to completely avoid this problem, consider setting up a staging area for A/B testing and content transfers.

What Distinguishes a WordPress Clone from a Duplicate?

A duplicate in WordPress is a new entry that uses information from an already-existing page, whereas a clone contains an identical copy of the content.

Conclusion

However, the ability to copy a WordPress page or post is really helpful, whether you’re trying to optimize your design process or are looking into creative ways to create content.

In this post, we looked at two approaches for copying a page in WordPress:

  • Employing a plugin for WordPress duplicate posts: Moreover, this is an easy-to-use approach that may be used to replicate a lot of pages.
  • Modifying the functions.php file with unique code: Further, if you would like more customization options for the duplicate post link or are unable to access your admin dashboard, go with this method.

We hope that this post has given you more insight into the various ways that WordPress page duplication might improve your website-building process.