WordPress Duplicate Page – The Easy Way

Share:

Are you looking for a way to easily duplicate a page in WordPress? In this article, we will show you how to do just that. 

WordPress Duplicate Page – The Why

WordPress is a great tool for creating a managing content. It’s one of the most popular CMSs for a reason. Using WordPress you can create and manage website content (pages), blog content (posts), and if you are using it for ecommerce you can also create and sell products.

In some cases, you may want to quickly make a copy of existing content (a page, post, or product), and use it as a starting point. This is where the WordPress duplicate page method comes in. There are several ways that you can accomplish this in WordPress.

In this article, we will show you a few, including our preferred method.

Option 1 – The plugin route

Our favorite and the simplest way to duplicate almost anything in WordPress is to use the WordPress Duplicate Page plugin. You can install and activate this free and lightweight plugin in no time.

Don’t let the name fool you. This plugin can duplicate pages, posts, products, and even Elementor templates. Once you install and activate this plugin, you will see an option to duplicate any object by clicking Duplicate This (see screenshot below).

Click on the Duplicate This button to create a copy of the content which will be stored in Draft mode. After you make changes to the new duplicated copy, make sure you hit the Publish button.

wordpress-duplicate-page-screenshot-clio-websites
WordPress Duplicate Page Plugin – Source: wordpress.org plugins directory

Option 2 – Duplicate content manually

You can also duplicate content manually by copying and pasting the page content. This approach will depend on whether you are using the Gutenberg block editor, Elementor, or something else, but the steps are more or less the same.

Follow these steps to duplicate pages or posts in WordPress using the block editor:

  1. Create a new page or post manually
  2. Open the page or post you want to duplicate
  3. In the block editor, click on the three dots in the top right of the page
  4. Select the Copy all content option
  5. In the new page or post (created in step 1), paste all of the content that you copied
  6. Update and save the page / post settings and click on Publish

Option 3 – Duplicate content using code

It’s also possible to add the duplicate page feature by adding some code to your website. You have to be comfortable with working with child themes and adding code to your theme’s functions.php file.

In your child theme, open the functions.php file and add the following code:

/*
 * 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('page_row_actions', 'rd_duplicate_post_link', 10, 2);

Save the file and you will now see a Duplicate option when you scroll over the pages in WordPress. Note that this code option only works for duplicating pages.

wordpress-duplicate-page-clio-websites-screenshot
WordPress Duplicate Page – Code Method Screenshot

Option 4 – Duplicate content using Elementor Pro

There are a few ways to duplicate WordPress content using Elementor. Elementor is a really flexible builder and you can copy and paste objects easily across pages, and even across different websites.

All you have to do is select a section, right-click on it, and select copy (see the screenshot below).

wordpress-duplicate-page-elementor-copy-screenshot-clio-websites
WordPress Duplicate Page – Elementor Copy Section Feature

Create a new Elementor page or post and open the editor. On your new page right click on the plus sign in the “drag widgets here” section, and select Paste.

wordpress-duplicate-page-elementor-screenshot-clio-websites
If you use this method to duplicate content in WordPress, you will have to do this for each section.

There is an even easier way to duplicate content in Elementor. If you have the pro version of Elementor, you can also duplicate WordPress content using the export and import feature. You can also create templates using Elementor and apply them across your website easily and quickly.

How to duplicate content using the Elementor export and import template feature:

Step 1

edit-page-wordpress

Open the page or post that you want to duplicate.

Step 2

create-template-screenshot-elementor-clio-websites

Look for the Publish (or Update) button, click on the up arrow to open the secondary menu, and click on Save as Template.

Step 3

import template screenshot elementor clio websites

Create a new Elementor page that you want to duplicate content to, and click on the Add Template button.

Step 4

elementor-template-screen

When the new window opens, click on My Templates, and select the template that you created in Step 2 and insert it by clicking Insert.

Step 5

elementor-publish-button-wordpress

Save and publish your new page, and you are done!

Conclusion

We hope that this blog post has helped you explore some popular WordPress duplicate page options. Check out our blog for more articles like this, or contact us if you have any questions.

About Clio Websites

Clio Websites is a full-service website design and marketing company in Calgary. We have vast experience in responsive website design, website maintenance, WordPress development and support, and SEO.

Clio offers free consultations and free website evaluations and we receive glowing reviews from our clients. We are Calgary web design experts, so don’t hesitate to get in touch with us.

WordPress Duplicated Page FAQs

Can you duplicate a page on WordPress?

Yes, you can duplicate a page, post, or product in WordPress really easily. Our favorite and easiest way to do that is to install and activate the Duplicate Page plugin.

How do I duplicate a page in WordPress 2022?

Duplicating a page is really easy if you use the Duplicate Page plugin for WordPress. In this article, we also show you additional ways to accomplish this.

Leave a Reply

Your email address will not be published.

Our Latest Posts

Get in touch

Signup for our newsletter

If you are enjoying our blog, sign up for our newsletter. We promise not to spam you and you can unsubscribe at any time.