Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  WordPress FAQ  >  Discover the Steps to Duplicate WordPress Pages or Posts
Top Scroll

Discover the Steps to Duplicate WordPress Pages or Posts

 5 min

When you create a duplicate of your existing WordPress posts or pages, it can be used in several situations. It can be used as a template for future posts or a reference while redesigning your website.

Fortunately, you will get many ways to clone a post or page in WordPress. In this tutorial, you will get different methods for the same, so keep on reading!

Steps to Duplicate Pages or Posts with WordPress Plugin

You can easily create a copy of a page or post just by using a plugin. After you activate the plugin, you can clone the pages or posts in just one click.

Below are some of the best WordPress plugins to duplicate your posts and pages as well as their usage:

Duplicate Post Plugin

Duplicate Post plugin is one of the best options for this. It not only copies the content, but also duplicates the comments, slug, menu order, and much more!

Moreover, you can add title prefix or a suffix, which will help you know the difference between the original and copy.

Suppose you set “Copy of” as the title prefix. Then you duplicate a post titled “What is WordPress,” the duplicate name will appear as “Copy of What is WordPress.”

Below are the simple steps to clone your WordPress posts or pages using Duplicate Post:

  1. Install the plugin and activate it.
  2. In your WordPress dashboard, click on Pages -> All Pages (to clone a page) or Post -> All Posts (to clone a post).
  3. Go to the page or post you want to clone, and you will see two new options there — Clone and New Draft.
  4. To duplicate the selected post, click Clone or click on New Draft to create a cloned version of the selected post and open it in the post editor.

Related: How to Create a Page in WordPress?

Duplicate Page and Post

With Duplicate Page and Post plugin, you can clone WordPress pages and posts quickly. The plugin duplicates a page or post without changing its title, content, or style.

Even a newbie can use this plugin easily. Follow the below steps:

  1. Once the plugin is installed and activated, go to the All Pages or All Posts menu, based on what you want to duplicate.
  2. Go to the post or page you want to clone and click on Duplicate.
  3. The cloned post or page will appear as a new draft with the same name as the original. Then to edit the content, open the copy of it.

Post Duplicator

With Post Duplicator, you can create an exact copy of the selected post without changing the custom fields and custom taxonomies too.

Below are the steps to duplicate a WordPress page or post using Post Duplicator plugin:

1. Install the Post Duplicator plugin and activate it.
2. Go to the post or the page you want to duplicate, and click Duplicate Post or Duplicate Page.

You can customize some settings for the duplicated posts. Navigate to Tools -> Post Duplicator and set the post status (published, draft, or same as the original), post type, and post date. You can also adjust the duplicate’s title and slug.

Related: How to save a WordPress post or page as a draft?

Duplicating WordPress Page or Post Without Plugins

Apart from using plugins, you can also change some codes to duplicate WordPress pages and posts. Though it sounds tough, it is actually quite simple.

We recommend you to backup your website prior to editing any WordPress files.

The below code snippet will enable post duplication in WordPress:

/*
* 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'] = 'Duplicate';
}
return $actions;
}
add_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );

This snippet will work only for duplicating posts. For duplicating the WordPress pages, you will need to replace the last line with the below code:

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

Just paste the code to your functions.php file. For this, you can use File Manager, FTP client, or inbuilt WordPress file editor.

If you want to use WordPress file editor, go to Appearance -> Theme Editor, and select Theme Functions.

After successfully embedding the code above, you will see a Duplicate button in All Posts or All Pages menu.

Conclusion

This tutorial will surely answer all your questions about duplicating a post or page in WordPress. If you have any other tips or tricks for the same, you can share them in the comments below.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.