fbpx
Blog

How to Duplicate a Page or Post in WordPress

How to Duplicate a Page or Post in WordPress, featured image

If you’ve ever found yourself needing to duplicate a post or page in WordPress, you might know the pain of copying and pasting paragraphs and images back and forth between browser tabs. This is not only inefficient but can also lead to mistakes.

Fortunately, there are many different ways you can quickly make a copy of a post or page in WordPress. The available solutions vary in complexity and use case, so you’ll almost certainly be able to find one that suits your particular needs.

In this tutorial, we’ll go over some reasons you might want to duplicate your WordPress content and how it can impact your site’s search engine optimization (SEO). Then we’ll share five methods you can use to accomplish this task, depending on your goals. Let’s dive in!

Why You Might Want to Duplicate Your WordPress Posts or Pages

It’s true that there’s little sense in publishing the same post or page twice. In fact, this can result in negative consequences for your site’s visibility, which we’ll discuss shortly.

However, there are several other reasons why you may want to duplicate a post or page in WordPress.

Firstly, you might want to create a template for your articles so that your style and formatting remain consistent across your site. This can make your site look more professional and authoritative.

Duplicating posts can help you save time on content creation by enabling you to reuse complex layouts or other features that would take a lot of effort to recreate.

You can also use duplicate posts to test out changes to your content without touching the original version. Think of the secondary copy as a small-scale staging environment for your post.

Another reason you might want to duplicate a page is for A/B testing. This strategy works best if you make very slight changes between versions, so making an exact copy of the landing page or other content you want to test is usually the easiest way to go about it.

Finally, duplication is also sometimes used to move content from one site to another. You may be undergoing a site redesign, rebranding, or other website overhaul and want to make sure your old content is preserved.

How Duplicate Content Impacts SEO

There is a common misconception that publishing duplicate posts will result in a Google penalty. While this isn’t strictly true, having multiple live copies of the exact same post or page on your site could negatively impact your SEO.

Since your duplicate posts are optimized for the same keywords and contain all the same relevant content search engine users might find useful, your duplicate posts will end up competing with one another for a higher spot on search engine results pages (SERPs). This generally results in both copies ranking lower than they otherwise would.

For this reason, we don’t recommend publishing live versions of duplicate posts (except for situations such as A/B testing). Instead, this process should be used for streamlining your workflow or otherwise improving your site.

How to Duplicate a Page or Post in WordPress (5 Methods)

There are actually several ways to duplicate your WordPress posts and pages. Which method is best for you will depend on your goals. Here are five options you might try.

Method 1: Use a Duplication Plugin

For most, the easiest way to duplicate content is by using a plugin. This solution is ideal if you are planning to use duplicate posts to create templates or for A/B testing purposes.

The most popular post duplication WordPress plugin is Duplicate Post:

The Duplicate Post plugin.

A common alternative is Duplicate Page:

The Duplicate Page plugin.

Both plugins provide very similar functionality and settings. We’ll demonstrate this method using Duplicate Post, but the process is essentially the same for Duplicate Page.

First, install and activate the plugin on your WordPress site:

Installing Duplicate Post.

Then, navigate to Settings > Duplicate Post:

Configuring the Duplicate Post plugin's settings.

Here, you specify which elements you want to copy over from the original post to the duplicate. You can also select which post types to enable duplication for, and which user roles have permission to make copies of your content.

Once you’ve configured your settings and saved your changes, navigate to the Posts section of your WordPress dashboard. You’ll now see two new actions — Clone and New Draft:

The Clone and New Draft options from Duplicate Post in the Posts list.

Clicking on Clone will create a new draft that is a duplicate of the post you’ve selected. The New Draft option does the same but opens the secondary copy in the WordPress editor. There you can make any necessary adjustments to tweak the duplicate post.

You’ll also see a Copy to a new draft option in the admin toolbar:

The Copy to a new draft option in the admin toolbar.

You can use this button to duplicate a post when editing it in the WordPress editor or viewing it on the frontend of the site.

Method 2: Clone Your Content for Migration

While plugins such as Duplicate Post and Duplicate Page do enable you to bulk-clone posts and pages, the Duplicator plugin is better suited to making copies of several pieces of content to move them to another site:

The Duplicator plugin.

This plugin is also sometimes used to create website backups you can use to restore your content if your site becomes compromised. Duplicator is a useful solution if you want to use your existing site as a template for a new one, or if you’re undergoing a redesign or rebranding.

Once you install and activate it on your site, it will add a new link to your dashboard sidebar. Navigate to Duplicator > Packages to get started:

Accessing Duplicator > Packages.

Then click the Create New button:

Creating a new Duplicator package.

Duplicator will then walk you through the steps to copy your site’s content. You’ll need to name your package, select where to store it and what to include in it. If you only want to copy your posts, exclude all the tables under Archive > Database except for wp_posts and wp_postmeta:

Selecting the wp_posts and wp_postmeta database tables to create a Duplicator package.

Once Duplicator has built the package, download it to your computer:

Downloading a completed Duplicator package.

You can then migrate your posts to another site using File Transfer Protocol (FTP) and an FTP client such as FileZilla. For complete instructions, see Duplicator’s documentation.

Method 3: Duplicate Products Using WooCommerce

If you run an e-commerce site, maintaining consistency across your product pages is important. If you want to duplicate your WooCommerce products to create templates or variations, you’re in luck — the WooCommerce plugin enables you to do so out of the box.

Navigate to Products and hover over any item to reveal the Duplicate option:

The WooCommerce Duplicate option in the Products list.

Clicking on it will create a draft of a new product that is identical to the original. You can then edit this copy to create a new product page that matches the old one’s styling and formatting.

Method 4: Copy Content from the Block Editor

If you use the WordPress block editor (Gutenberg), you may be familiar with its Copy all content option. You can access it by opening the editor’s settings:

The Copy all content option in the Block Editor.

Clicking on this option in the menu will immediately copy the post’s contents and display a confirmation.

You can then paste your content into another post. The primary downside to this method is that it doesn’t copy any of the post’s metadata, such as its title, taxonomies, permalink, and featured image.

Although a plugin such as Duplicate Post might take some time to set up initially, it will ultimately be a more efficient solution if you plan to make copies of your posts with some frequency.

Method 5: Create a ‘Duplicate’ Option by Editing Your Theme

The last method we recommend to duplicate a post or page in WordPress is to create a ‘Duplicate’ option by editing your theme. This technique is a little more advanced. However, if you execute it properly, it can seamlessly integrate duplication functionality with your site.

First, you’ll need to create and activate a child theme. This will ensure you can safely update your theme without losing your custom duplication feature.

Then, make a backup of your site in case the worst happens during the code editing process. Once both of those steps are done, you can safely move on to modifying your files.

The file you’ll need to edit is called functions.php. You can find it in your child theme’s folder via FTP and FileZilla, or simply use the built-in WordPress Theme Editor:

The WordPress Theme Editor.

Then add the following code to 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'] = '<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 );

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

Note that we added an extra line to the end of the original GitHub Gist to enable the feature not only for posts but also for pages, so copy it from here if you also want to duplicate pages.

Save the file. There will now be a Duplicate option in the Posts and Pages sections of your dashboard:

A custom Duplicate option created by editing the functions.php file.

Clicking on this option will create a duplicate post or page and open it in the WordPress editor so that you can modify it.

Conclusion

Being able to easily duplicate your WordPress content can come in handy in a wide variety of situations. When you don’t have to laboriously copy and paste portions from one browser tab to another, you minimize the risk of making a mistake along the way.

In this tutorial, we shared five unique methods you can use to duplicate a post or page in WordPress:

  1. Use a plugin such as Duplicate Post.
  2. Clone your site with a plugin such as Duplicator.
  3. Duplicate WooCommerce products using its native functionality.
  4. Copy a post’s contents in the block editor.
  5. Create a ‘Duplicate’ option by adding custom code to your theme.

Do you have any questions about duplicating your WordPress posts and pages? Leave them for us in the comments section below!

Share This Article:
Facebook Twitter

Related Posts

Leave a Reply


Your email address will not be published. Required fields are marked *