Duplication of a WordPress page doesn’t mean copy it from elsewhere on the Internet, and doesn’t like stealing from somewhere. We are talking about duplicate a page in WordPress that you already owned. It can be done with the help of plugins as well as manually. Let’s discuss further why you need a duplicate page in WordPress.

Why Duplicate a page in WordPress?

Why you need to duplicate your website’s content, this question is right and answerable as well. Making duplicate a page in WordPress could have the following reasons:

  • You want to change the design or layout of your current page withholding pages as is it.
  • You want to transform your website on another platform without losing your pages.
  • Regular duplication of WordPress itself a smart strategy to avoid any cautious situations.

There could be some reasons according to the individual prerequisites. We will examine with plugins and manual as well. Let’s start with WordPress plugins to duplicate a page in WordPress.

Duplicate a Page using WordPress Plugins

Thanks to WordPress plugins which make page duplication so easy, even you can duplicate pages with just clicks. These are the top 3 WordPress plugins to duplicate a page.

1 – Duplicate Page Plugin

Duplicate a page in WordPress

Duplicate page plugin can help you in the page, post, and any other content you want to duplicate. As soon as you install it on your WordPress, this option will be available on your dashboard. Let’s see how it works:

  • Heads to the plugins section on your dashboard and searches for “duplicate page.
  • Install and activate that plugin.
  • Now go to pages -> All pages on your dashboard.
  • A new screen will appear on your WordPress that contains all of your pages.
  • Hover the cursor over the page you want to duplicate; you will get multiple options, including ‘clone‘ and a new draft.
  • Click on ‘clone‘ if you want to make just a duplicate page; if you want to edit it also then click on ‘new draft.

That’s it. It is as simple as sound.

2 – Duplicate Page and Post Plugin

This method is similar to the first method of duplicate a page in WordPress but a little speedy than earlier and duplicates every page as it is. You can duplicate posts as well with this plugin. Follow the below instructions:

Duplicate a page in WordPress

  • Install and activate the plugin as I mentioned earlier.
  • Similarly, locate the Pages->All pages Or Posts->All posts.
  • Hover the cursor over the particular post or page you want to duplicate and click on ‘duplicate.

After completing all these processes, your new duplicate page appears on the new draft as the same as your original content.

3 – Duplicate Post

Although all the methods are almost similar, I am mentioning all the methods to let you know to use them according to your preferences.

Duplicate a page in WordPress

  • Install and activate the plugin as already mentioned.
  • Head to the pages in your dashboard.
  • Now go to the pages or posts section, whatever you want to duplicate.
  • Again, hover to the particular post or page to make duplicate click on ‘duplicate page.’

Your duplicate pages will create on a new draft or editor.

Duplicate Pages Without Plugins

You can easily create a duplicate post or duplicate page without using any plugin, though, although it is not as good as with a plugin because it is time-consuming. I do not recommend this method until it too emergency, but you should have all arrows on your quiver.

Duplicate with function.php

This is the easiest method when we consider manual techniques. You just have to copy and paste a code on your server. I highly recommend making a backup to avoid any troublesome activities.

  • Go to your WordPress dashboard and head to your theme settings.
  • You have opened a lot of options but search for function.php.
  • Open the function.php and go for editing with secure FTP (file transfer protocol).
  • I am providing a code snippet below; paste that code at the end of your function.php 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( 'page_row_actions', 'rd_duplicate_page_link', 10, 2 );

[You can use this code to duplicate post of your WordPress post by replacing the page with a post in the last two lines]

Manual Copy Editor

The manual copy editor method is the least method to recommended as it is a very time-consuming process. You have to copy the code of the individual page and then paste it to the new page you want to create.

  • Go to the page you want to duplicate.
  • On the toolbar, select code editor instead of visual text.
  • Then copy all the codes of the individual page.
  • Now open a new page and paste this code on the code editor of that page.
  • You can check whether the code is pasted properly or not by click on the visual text.

Conclusion

Above are some popular methods to duplicate a page in WordPress. You can do this with or without plugins, but I recommend using plugins to save your time.

Furthermore, the plugin makes it easier to perform the task as you just need to click on the duplicate button. I hope you understand all the methods properly but if you have still any doubts then let me know.

Leave a Reply