WordPress

How To Duplicate a WordPress Page or Post in Mere Seconds

August 7, 2020

Need to duplicate a WordPress page or post? In this tutorial, you’ll learn how to duplicate a WordPress page, post, or custom post type with just a few clicks.

In fact, duplicating a WordPress page is almost as simple as importing a post or page from Google Docs to WordPress with Wordable.

In this post, you’ll first learn how to use two free WordPress plugins to duplicate a page or post. Then, you’ll also find out how you can add your own code snippet to get similar functionality without the need to install a new plugin.

Let’s dive right in so that you can get to duplicating.

Still copying content into WordPress?

You’re doing it wrong… say goodbye forever to:

  • ❌ Cleaning HTML, removing span tags, line breaks, etc.
  • ❌ Creating your Table of Contents anchor ID links for all headers by hand,
  • ❌ Resizing & compressing images one-by-one before uploading back into your content,
  • ❌ Optimizing images with descriptive file names & alt text attributes,
  • ❌ Manually pasting target=“_blank” and/or “nofollow” attributes to every single link
Get 5 free exports

Why WordPress Page and Post Duplication Is Essential

They say that insanity is when you “do the same thing over and over again, but expect different results.”

Well, setting up multiple pages over and over again without a template or duplicator is a time-consuming process that could also feel like insanity.

The process occupies a lot of time that marketers or developers could use working on something more valuable.

Without a post duplicator plugin, marketers have to use a template or start from scratch on a new page. This is tiresome when you have to create multiple pages that have similar or duplicated content.

Since personalization and targeted campaigns are the most effective way to convert new customers, businesses need multiple landing pages with slight variations.

You may have to create five different landing pages with the same content, but slightly different copy variations, custom fields, or a new featured image.

This is why duplicating posts and pages is so essential, especially for WordPress websites. Multiple pages are essential for effective marketing campaigns on WordPress, and a page or post duplicator, often provided by WordPress development services, will save time and make the business run more efficiently.

Let’s take a look at the three most common ways to duplicate a page or a post on your website.

Works on Pages and Posts

The easiest way to duplicate a page is with a free WordPress plugin called Duplicate Page.

It’s super simple. To start, install and activate this free plugin by going to Plugins → Add New and searching for it by name:

Install and activate the plugin

There’s plenty of plugins available in WordPress’ plugin marketplace. From WordPress SEO plugins to different WordPress theme plugins, there’s no limit to what you can find.

Then, go to the Posts or Pages area in your WordPress dashboard. Hover over the post or page that you want to duplicate and click Duplicate This:

click "Duplicate This"

After clicking that button, the plugin will duplicate the page and create a new copy as a draft. It won’t make the copy of your page public:

The duplicate will show as a draft

And that’s all there’s to it! You’ll be able to work with the cloned page just as if you’d created it from scratch.

If you want, the plugin also includes some more advanced settings that let you control:

  • Access: which users have the ability to duplicate posts or pages.
  • Status: the status to assign to the duplicated copy. For example, you can automatically publish the duplicate page.
  • Custom Titles: whether to append some text to the end of the duplicated copy to help differentiate it. For example, you could add “- Duplicate Version” after the title of a duplicated post.

To access these settings, go to Settings → Duplicate Page:

Duplicate page settings

Lets You Bulk Duplicate WordPress Pages

As an alternative to the WordPress Duplicate Page plugin above, there’s also another popular free plugin called Duplicate Post.

Like the WordPress Duplicate Page plugin, this plugin also lets you clone both posts and pages. But, where this plugin goes a bit further is that it also lets you clone pages or posts in bulk.

So if you need that bulk functionality to copy multiple pages, that might be a reason to go with this plugin.

To start with the plugin, you can install it by going to Plugins → Add New and searching for it by name:

Duplicate pages/posts in bulk

Once you’ve activated the plugin, go to the Posts or Pages area in your WordPress dashboard. Find the piece of content that you want to duplicate.

Then, hover over it. You should see two new choices. Both of them duplicate your page, but the difference lies in what happens after that:

  • Clone: will create a draft copy of the post and keep you in the same list view.
  • New Draft: will create a copy of the post and open it in the WordPress dashboard. You can start working with it right away.
Locate the Clone or New Draft options

So if you want to get to work on your duplicated page right away, you can click on New Draft to save yourself a click. Otherwise, there’s not much difference.

If you want to duplicate multiple WordPress posts or pages, you can use the checkboxes on the left to select multiple pieces of content. Then, you can use the new Clone choice in the Bulk Actions drop-down to clone all the content that you’ve selected with one action:

Duplicate pages in bulk option

Beyond those choices, you’ll also get a new Copy to a new draft choice on the WordPress toolbar. It’ll appear when you’re editing a post or page:

Copy to a new draft

And like the WordPress Duplicate Page plugin from above, the Duplicate Post plugin also includes some added settings that let you control things like:

  • Custom Elements: which content elements to copy. For example, you can choose whether or not to copy the published date or duplicate the post attachments.
  • Custom Titles: adding content to the duplicate copy (like automatically adding “Duplicate Copy” to the end of a cloned post’s title).
  • Accessibility: Which user roles can use the duplicate page functionality.

To access these settings, go to Settings → Duplicate Post:

Duplicate Post settings

And that’s it! Pretty easy. If you’re up for a greater challenge, why not duplicate your pages or posts by writing your own code?

How to Duplicate WordPress Pages or Posts with Your Own Code

Finally, you can also get your hands dirty and use your own code to duplicate pages or posts. There’s no real advantage to using this route, as both of the plugins above are already pretty lightweight by themselves.

However, if you want the leanest, meanest way to duplicate a page and/or you don’t want to worry about maintaining yet another plugin, this method works totally fine.

Sometimes plugins can slow down your website’s speed, which will have a bit of an impact on its ranking in search engines. However, that shouldn’t be a reason to shy away from them.

Instead, it’s something to keep in mind as you build your website. Manually coding duplicated pages can avoid site speed issues altogether, which is why some marketers or web developers opt to take this route.

To add this code to your WordPress site, you can:

  • Add it to your child theme’s functions.php file (make sure you use a child theme. If you don’t, your code will disappear the next time that you update your theme).
  • Use a plugin like Code Snippets, which most people find to be a more convenient way to manage code. Using this plugin also ensures that you won’t lose your duplicate page functionality if you ever switch your WordPress theme in the future.

Here’s the code snippet that you’ll need to add to one of those areas:

  1. /*
  2. * This code duplicates a WordPress page. The duplicate page will appear as a draft and the user will be redirected to the edit screen.
  3. */
  4. function rd_duplicate_post_as_draft(){
  5. global $wpdb;
  6. if (! ( isset( $_GET[‘post’]) || isset( $_POST[‘post’]) || ( isset($_REQUEST[‘action’]) && ‘rd_duplicate_post_as_draft’ == $_REQUEST[‘action’] ) ) ) {
  7. wp_die(‘No post to duplicate has been supplied!’);
  8. }
  9. if ( !isset( $_GET[‘duplicate_nonce’] ) || !wp_verify_nonce( $_GET[‘duplicate_nonce’], basename( __FILE__ ) ) )
  10. return;
  11. $post_id = (isset($_GET[‘post’]) ? absint( $_GET[‘post’] ) : absint( $_POST[‘post’] ) );
  12. $post = get_post( $post_id );
  13. $current_user = wp_get_current_user();
  14. $new_post_author = $current_user->ID;
  15. if (isset( $post ) && $post != null) {
  16. $args = array(
  17. ‘comment_status’ => $post->comment_status,
  18. ‘ping_status’ => $post->ping_status,
  19. ‘post_author’ => $new_post_author,
  20. ‘post_content’ => $post->post_content,
  21. ‘post_excerpt’ => $post->post_excerpt,
  22. ‘post_name’ => $post->post_name,
  23. ‘post_parent’ => $post->post_parent,
  24. ‘post_password’ => $post->post_password,
  25. ‘post_status’ => ‘draft’,
  26. ‘post_title’ => $post->post_title,
  27. ‘post_type’ => $post->post_type,
  28. ‘to_ping’ => $post->to_ping,
  29. ‘menu_order’ => $post->menu_order
  30. );
  31. $new_post_id = wp_insert_post( $args );
  32. $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array(“category”, “post_tag”);
  33. foreach ($taxonomies as $taxonomy) {
  34. $post_terms = wp_get_object_terms($post_id, $taxonomy, array(‘fields’ => ‘slugs’));
  35. wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
  36. }
  37. $post_meta_infos = $wpdb->get_results(“SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id”);
  38. if (count($post_meta_infos)!=0) {
  39. $sql_query = “INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) “;
  40. foreach ($post_meta_infos as $meta_info) {
  41. $meta_key = $meta_info->meta_key;
  42. if( $meta_key == ‘_wp_old_slug’ ) continue;
  43. $meta_value = addslashes($meta_info->meta_value);
  44. $sql_query_sel[]= “SELECT $new_post_id, ‘$meta_key’, ‘$meta_value'”;
  45. }
  46. $sql_query.= implode(” UNION ALL “, $sql_query_sel);
  47. $wpdb->query($sql_query);
  48. }
  49. wp_redirect( admin_url( ‘post.php?action=edit&post=’ . $new_post_id ) );
  50. exit;
  51. } else {
  52. wp_die(‘Post creation failed, could not find original post: ‘ . $post_id);
  53. }
  54. }
  55. add_action( ‘admin_action_rd_duplicate_post_as_draft’, ‘rd_duplicate_post_as_draft’ );
  56. function rd_duplicate_post_link( $actions, $post ) {
  57. if (current_user_can(‘edit_posts’)) {
  58. $actions[‘duplicate’] = ‘Duplicate’;
  59. }
  60. return $actions;
  61. }
  62. add_filter( ‘post_row_actions’, ‘rd_duplicate_post_link’, 10, 2 );
  63. add_filter( ‘page_row_actions’, ‘rd_duplicate_post_link’, 10, 2 );

For example, here’s what it looks like in the Code Snippets plugin (you can access this area by going to Snippets → Add New):

Code Snippets interface

Once you add the code, you’ll see a new Duplicate option when you hover over a post or page. Clicking it will duplicate the piece of content and open a draft of the copy in the WordPress editor:

Duplicate option

And that’s all there is to it!

Manually duplicating a WordPress post or page is a great thing to do if you have the time.

By learning the code and custom scripts required to duplicate a page, you will improve your understanding of how your entire WordPress site is set up. This can help you built out other portions of your website that might require similar plugins or lines of code.

You won’t have the more detailed settings options that the plugins offer, but the core duplicate content functionality will work just fine.

Final Thoughts

Marketers are busy. The time they save from having to manually create an entire new page or post instead of duplicating it can be better used in other aspects of the company. To put it simply: WordPress duplicate page plugins are a game changer for those managing your website.

Whether you use a plugin or your own code, all the methods in this post will let you duplicate any WordPress post or page with just a single click.

The two plugins are both easy to set up and let you start duplicating content right away. But if you want to keep things more lightweight and avoid installing a new plugin, you can always use your own code snippet instead.

Finally, if you like the ease of being able to move your content with a single click, then Wordable might just be your new best friend. It lets you import content from Google Docs to WordPress with the click of a button. Then, once you get your Google Docs content into WordPress, you can duplicate it as many times as needed with the methods in this tutorial.

Click here to learn more about how Wordable can speed up your content creation process.

Kevin Kessler
Kevin J. Kessler is a published author of five fantasy novels, a professional wrestler, and a puppeteer (not all at the same time). Kevin is a content writer at Codeless.
Kevin Kessler
Kevin J. Kessler is a published author of five fantasy novels, a professional wrestler, and a puppeteer (not all at the same time). Kevin is a content writer at Codeless.