How to Duplicate a Page in WordPress (and posts too!)

There are a few ways to duplicate WordPress pages or posts, and this article will show them to you. One of the reasons why you need to create a copy of your existing contents is that you want to do a rewrite. Furthermore, you may need to copy the exact same content to another website (with all of its elements, such as images, SEO data, and layouts).

Whatever reasons you may have, you want it done in the fastest but simplest ways possible.

Three Ways to Duplicate WordPress Pages or Posts:

1. Use a Plugin

The easiest way to make an exact copy of your pages is to use a plugin. There are many free and paid duplicate page plugins available at WordPress.org, and most of them work for posts and custom post types, too. Here are some of the plugins we have tried and a few details to help you choose which one to use.

Copy & Delete Posts / Duplicate Post Plugin

Duplicate Post WordPress Plugin

Copy & Delete Posts plugin aka Duplicate Post lets you decide which elements in your pages or posts (title, slug, excerpt, content, featured image, etc.) you want to include in the duplicate. 

Here’s how Copy & Delete Posts plugin works:

  • Download and activate from your WP dashboard or get a copy here.
  • Upon activation, you will be redirected to the Welcome page wherein you can customize the settings. 
How to use the duplicate post plugin instructions
  • Start duplicating pages or posts, which the plugin allows in its free version. Go to Dashboard > Pages > All Pages or Dashboard > Posts > All Posts depending on what content type you want to duplicate.
  • Hover over the item you want to clone and click on “copy”. A draft copy will then appear on the list. 
Duplicate post context menu in pages

Should you need to copy all, select all items, and click copy from the Bulk actions menu. 

Duplicate Post copy option in dropdown menu

Yoast Duplicate Post

Yoast Duplicate Posts Plugin

Yoast Duplicate Post plugin gives you the following additional options:

  • Clone
  • New Draft
  • Rewrite & Republish
Yoast duplicate post plugin context menu

The Clone option lets you create a draft copy of a post or page without leaving the list page. This is useful when you just want to clone an item and work on it later. We also find this helpful when we want to leave draft copies for specific writers and let them do their own revisions.

Choose the New Draft option when you want to create a clone of a page or post and edit it right away. This will not delete the original item. 

The Rewrite & Republish option creates a draft copy, directs you to the editor, and deletes the original item when you click the Republish button.

Republish Option Yoast Duplicate Post Plugin

The features mentioned above are available in the free version of the plugin. Search for Yoast Duplicate Post from your WP Dashboard > Plugins > Add New or download a copy here.

Quick Post Duplicator

Quick Post Duplicator Plugin

Quick Post Duplicator lets you — as the name of this plugin suggests — quickly duplicates any and all post types(page/post/custom post type), with all of their taxonomies, featured image, and custom fields. However, unlike the other two plugins we show in this article, Quick Post Duplicator does not have the option to customize settings to choose what to include in the clone. The copy option, just like the other two plugins, is found on the page / post list page. 

You can download a copy of the Quick Post Duplicator here

2. Duplicate WordPress Pages and Posts via Functions.php

There are several ways to duplicate a page or post without a plugin. One way is via the functions.php file. This manual option to enable the cloning of pages and posts is actually easier than it sounds. All you need to have is a code snippet that you can add to the end of your functions.php file. Here are the steps:

  1. Create a backup of your website first just to be on the safe side. You will be editing a critical file in your site, and a slight misplacement of codes may cause a massive error. Nonetheless, you just need to copy and paste a code snippet, so it should not cause trouble.
  2. Access the function.php file. Using a secure FTP is the most common way to do this. Open the file and edit. 
  3. To enable duplicating of pages, copy and paste the following at 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 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 );

  4. The next thing you want to do is to enable cloning of posts. Just use the same code snippet, but replace the last line, which is as follows:add_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );
    with this:
    add_filter('page_row_actions', 'rd_duplicate_post_link', 10, 2);
  5. Save and upload the file again to your server. Make sure to remove the old file.
  6. Go to your WordPress Dashboard > Pages / Posts > All Pages / All Posts. You should be able to see the Duplicate option when you hover over a page or post in the list.

3. Copy and Paste Post or Page code

If you think you don’t need to do a lot of cloning, then this option is for you. Obviously, this is a more manual way to duplicate WordPress pages and posts than adding a snippet into your functions.php file. It’s because you need to copy each individual post’s or page’s code. Here are the steps:

  1. Go to the editor’s page of the page / post that you want cloned. 
  2. Click on the Settings icon and click Code Editor. 
  3. Copy the code that appears on the editing field.
Code Editor Option in WordPress
  1. Create a new page or post, whichever is applicable, and paste in the code. To check whether you have pasted the exact same texts you copied, you may opt to exit the code editor and move to visual editor (see step 2).
  2. Click Save Draft or Publish.
  3. You should be able to see the duplicate on the pages or posts list. 

Please note that other than the texts and their layout, with this copy and paste option, you have to manually copy the title, featured image, taxonomies, etc.

If you have a lot of duplicating to do, then it’s best to either choose a plugin or edit your functions.php file.

There you have it! We hope this article helps you find the right method to duplicate WordPress pages and posts. Thank you for reading.