How to Duplicate a Page or Post in WordPress Fast and Easy

Cloning or duplicating a page or post in WordPress is simply more than just copy and pasting the content from one page to another.

You could manually copy and paste the content which are the texts and images of the page or post to a new draft. However, this does not copy all the associated data like the post settings, SEO settings, and other metadata.

WordPress Metadata

Now, I mentioned WordPress post metadata above. But what is WordPress metadata and why it is important for page or post duplication?

In a nutshell, think about a photo taken on your phone. Any information about that photo, like when and where it was captured, would be considered metadata for that photo. Now, if you duplicate that photo you will also duplicate its metadata, but if you only take a screenshot of that photo to copy and paste it, then the metadata of that photo will not get duplicated.

In WordPress posts metadata, the most common you can actually see are the post category, author and date posted. Most of the post metadata is not visible and is only used for functionality purposes by your theme or one of the plugins on your WordPress site.

WordPress Metadata

What is the difference between WordPress Page and Post?

I also mentioned WordPress “Page or Post” for duplication. But really, what is the difference between the two?

Many beginners to WordPress find the difference between a page and a post hard to understand. To simplify, pages are used for timeless static or “one-off” content such as your privacy policy, about us, and contact page. Whereas, posts are for more timely content that is regularly updated such as your blog posts.

Safely and Easily duplicate pages or posts in WordPress

In this article, we’ll look at how to clone or copy a WordPress page or post safely and easily, and introduce some of the widely used plugins that can help.

The fastest and easiest way to duplicate a WordPress page or post is by installing a plugin. There are millions of plugins on WordPress, literally. But worry not as we list the easiest, light, safest plugin you can use right away on your WordPress site. All you have to do is install and activate the plugin and then you can start duplicating pages and posts.

1. Yoast Duplicate Post (Recommended)

Yoast Duplicate Post Plugin

With 3+ Million active installations. Yoast Duplicate Post is the most trusted and commonly used WordPress page or posts duplication plugin.

How to use Yoast Duplicate Post plugin.

  1. Install and activate the plugin.
  2. In your WordPress dashboard, go to Posts » All Posts when duplicating posts, or Pages » All Pages when duplicating pages.
  3. Hover over the page or post you want to duplicate, and click on Clone to duplicate it.
Hover and duplicate page by clicking on Clone link

If you want to duplicate multiple pages or posts all at once, you can duplicate by selecting the checkbox on the left side of the title and then click on Bulk Actions.

Duplicate pages all at once by using WordPress bulk action

2. Duplicate Page

Duplicate Page WordPress plugin

The Duplicate Page plugin is our 2nd recommended page and posts duplication plugin. With 1+ Million active installations, by the installation numbers themselves, you’ll know that a million WordPress sites are actively using it and are happy with the result. We also extensively test these plugins ourselves.

How to use Yoast Duplicate Post plugin.

  1. Install and activate the plugin.
  2. In your WordPress dashboard, go to Posts » All Posts when cloning posts, or Pages » All Pages when duplicating pages.
  3. Hover over the page or post you want to duplicate, and click on Duplicate This to duplicate it.
Hover and duplicate page by clicking on Duplicate This link

Duplicating WordPress page or post without using a plugin

For most intermediate to advanced WordPress site owners, you don’t have to use a plugin to duplicate a page or post. This can be done manually by pasting a code snippet directly on your functions.php or by using the code snippets plugin.

backup-warning

You’ll need to access your functions.php file and open it for editing, using Secure File Transfer Protocol (FTP) or whatever other method you prefer. We recommend you use the code snippets plugin for any custom code you want to add to your functions.php. See our guide on how to use the code snippets plugin. Read our guide on how to safely add custom code safely in WordPress.

You can enable page and post duplication manually by adding the code snippet below.

/*
 * WPToro.com | Duplicate Page and Post Function
 */
function wptoro_duplicate_post_as_draft() {
    global $wpdb;
    if (!(isset($_GET['post']) || isset($_POST['post']) || (isset($_REQUEST['action']) && 'wptoro_duplicate_post_as_draft' == $_REQUEST['action']))) {
        wp_die('Uh oh! No Post to duplicate found.');
    }

    if (!isset($_GET['duplicate_nonce']) || !wp_verify_nonce($_GET['duplicate_nonce'], basename(__FILE__)))
        return;


    $post_id = (isset($_GET['post']) ? absint($_GET['post']) : absint($_POST['post']));
    $post = get_post($post_id);

    $current_user = wp_get_current_user();
    $new_post_author = $current_user - > ID;

    if (isset($post) && $post != null) {

        $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
        );

        $new_post_id = wp_insert_post($args);

        $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);
        }

        $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);
        }

        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_wptoro_duplicate_post_as_draft', 'wptoro_duplicate_post_as_draft');

function wptoro_duplicate_post_link($actions, $post) {
    if (current_user_can('edit_posts')) {
        $actions['duplicate'] = '<a href="'.wp_nonce_url('admin.php?action=wptoro_duplicate_post_as_draft&post='.$post - > ID, basename(__FILE__), 'duplicate_nonce').
        '" title="Duplicate this item" rel="permalink">Duplicate</a>';
    }
    return $actions;
}

//Enable Post Duplication
add_filter('post_row_actions', 'wptoro_duplicate_post_link', 10, 2);
//Enable Page Duplication
add_filter('page_row_actions', 'wptoro_duplicate_post_link', 10, 2);

After adding the code snippet on your functions.php, A Duplicate button should now appear when you hover over a page or post you want to duplicate.

Hover and duplicate page by clicking on Duplicate link

Conclusion

We hope that this guide answers all your questions about how to duplicate a page or post in WordPress.

To summarize and just a quick recap.

We now know basically what is WordPress Metadata and what is the difference between a page and a post. Also, we now know that we can duplicate a WordPress page or post by using a WordPress plugin. The two recommended plugins for page and post duplication in WordPress are Yoast Duplicate Post and Duplicate Page.

Second, for intermediate and advanced WordPress website owners. You can copy pages or post in WordPress by just adding a code snippet on your functions.php and skip using a plugin.

If you have any difficulties applying this guide on your WordPress website, please leave a comment below and we would gladly answer them.

Also, if you know more advanced tips and tricks for duplicating or cloning a WordPress page or post, please leave a comment below so that other people will see them and apply that on their own WordPress website.

– Team WPToro ❤️