How to Duplicate a Page in WordPress 2023 (3 ways)

By.

min read

block-editor-copy-all2

Looking for the most convenient ways how to duplicate a WordPress page? Well, your search is over.

Sometimes it would be very convenient to copy the whole page or post’s content and all of its settings instead of doing all this by hand. Not only your title and the content would be copied but also the categories, tags, meta details like page settings, and more.

We have found multiple ways how to do exactly that. Starting from simpler methods such as using plugins, to more advanced ones like using custom code and even manual methods for block editor and Elementor page builder content duplication.

1. Duplicate a page with free WordPress plugins (recommended)

The most simple and widely used method is through one of the free WordPress plugins. That’s why we have found the 2 most popular WordPress page and post duplicate plugins that should provide you with all the functionality you might need.

Yoast Duplicate Post (by Enrico Battocchi & Team Yoast)

Yoast Duplicate Post plugin options page

Currently, the most popular post duplication plugin is the Yoast Duplicate Post with more than 4 million active installations. Some of its popularity could be related to another plugin by the same developers – Yoast SEO – which is also very popular in its field.

The Yoast Duplicate Post plugin has many useful options such as indicating the data to use when duplicating, inputting the prefix or suffix to use for the new title, selecting user roles that can perform duplication, choosing which actions will be displayed and where, and more. By default, the plugin works just fine out of the box, but it is nice to know that there are many useful options that could be handy in different use cases.

Duplicate Page (by mndpsingh287)

Duplicate Page plugin options page

The second most popular plugin is the Duplicate Page with more than 2 million active installations. This plugin is much simpler than the previously mentioned one as it offers only a few options, but in most cases, those could also be enough. The options include post status, redirection page, post suffix, and the option to choose which editor you are using.

2. Duplicate Page in WordPress without Plugins

If you don’t feel like using plugins then you can use the PHP code snippet below. The snippet works by adding a “Duplicate” action for your pages and posts. After clicking on the new action you will be redirected to a freshly created draft to edit it. The code can be inserted at the end of your theme’s “functions.php” file (it is better to use a child theme for this purpose) or in any custom plugin you have created for your website.

/*
 * Post duplication functionality
 */
function shufflehound_duplicate_post() {

    // Verify nonce
	if( empty( $_GET[ 'post_id' ] ) || !isset( $_GET[ 'duplicate_nonce' ] ) || !wp_verify_nonce( $_GET[ 'duplicate_nonce' ], basename( __FILE__ ) ) ) {
		wp_die( 'Post duplication failed' );
	}

    // Check if post exists
    $post_id = !empty( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : false;
    $post = get_post( $post_id );
    if( !empty( $post ) ) :
        $current_user = wp_get_current_user();
        $current_user_ID = !empty( $current_user->ID ) ? $current_user->ID : false;

        // Duplcate the post
        $args = array(
            'comment_status' => $post->comment_status,
            'ping_status'    => $post->ping_status,
            'post_author'    => $current_user_ID,
            '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 );

        // Duplicate the terms
        $taxonomies = get_object_taxonomies( $post->post_type );
        foreach( $taxonomies as $taxonomy ) :
            $post_terms = wp_get_object_terms( $post_id, $taxonomy, ['fields' => 'slugs' ]);
            wp_set_object_terms( $new_post_id, $post_terms, $taxonomy, false );
        endforeach;

        // Duplicate the post meta
        global $wpdb;
        $post_metas = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=%d", $post_id ) );
        if( is_array( $post_metas ) && count( $post_metas ) ) :
            $sql = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
            $sql_select = [];
            foreach( $post_metas as $post_meta ) :
                $meta_key = $post_meta->meta_key;
                if( $meta_key != '_wp_old_slug' ) :    
                    $meta_value = addslashes( $post_meta->meta_value );
                    $sql_select[] = "SELECT $new_post_id, '$meta_key', '$meta_value'";
                endif;
            endforeach;
            $sql.= implode( " UNION ALL ", $sql_select );
            $wpdb->query( $sql );
        endif;

        // Redirect to the edit post page
        wp_safe_redirect( admin_url( 'post.php?action=edit&post=' . $new_post_id ) );
        exit;

    else :
        wp_die( 'Post was not found with ID: ' . $post_id );
    endif;
}
add_action( 'admin_action_shufflehound_duplicate_post', 'shufflehound_duplicate_post' );

/*
 * Post duplication link for the post
 */
function shufflehound_duplicate_post_link( $actions, $post ) {
    if( current_user_can('edit_posts') ) :
        $actions['duplicate'] = '<a href="' . wp_nonce_url( 'admin.php?action=shufflehound_duplicate_post&post_id=' . $post->ID, basename( __FILE__ ), 'duplicate_nonce' ) . '">Duplicate</a>';
    endif;
    return $actions;
}
add_filter( 'post_row_actions', 'shufflehound_duplicate_post_link', 10, 2 );

3. Copy Page or Post Content Manually

Pages and posts can also be recreated manually without any fancy plugins or custom code. It won’t be so convenient but it could work for you if this functionality isn’t needed on daily basis. We have described 3 different ways to copy the main part of the page or post content depending on your page editor. It will be different for each page editor.

Block editor (Gutenberg editor)

Block editor edit page

For some time now the latest WordPress versions use the block editor as the main page and post editor. If you have a recent WordPress version and you haven’t disabled or replaced it with something different – most likely this will be the page builder you will be using.

Follow these steps below to duplicate the block editor content (for this example we will be duplicating a page, but it will work the same for posts):

  1. Choose the page you want to duplicate
  2. Go to the Edit page
  3. Click on the Options icon (3 vertical dots at the top right corner)
  4. Click on Copy all content
  5. Create a new page or post
  6. Click Paste (CTRL+V for Windows or Command+V for Mac) inside the block editor field
  7. Save your changes

Now that you have followed the steps – you have successfully duplicated a page in WordPress.

Classic Editor

Classic editor edit page

Older WordPress versions use the Classic Editor as the main editor. Don’t worry, there is a way to copy post and page content on this page editor as well.

To copy a page or post – follow these steps (for this example we will be copying a page, but it will work the same for posts):

  1. Choose the page you want to copy
  2. Go to the Edit page
  3. Switch from Visual to Text tabs (at the top right side of the content)
  4. Select all the text and copy it (CTRL+C for Windows or Command+C for Mac)
  5. Create a new page or post
  6. Click Paste (CTRL+V for Windows or Command+V for Mac) inside the content field (make sure that you still have the Text tab selected)
  7. Switch page to the Visual tab
  8. Save your changes

After following these steps – you have successfully copied a page’s content in WordPress.

Elementor Page Builder

Elementor page builder edit page

Currently, Elementor Page Builder is one of the most popular WordPress page builders. If you are using this page builder follow these easy steps to duplicate the page builder’s content:

  1. Open the page you want to copy in the Elementor page builder
  2. Right-click on the dotted bottom block (below the content)
  3. Select Copy All Content
  4. Create a new page
  5. Right-click at the dotted bottom block
  6. Select Paste

If you followed these steps, you now have successfully copied the content of an Elementor Page Builder.

Conclusion

Duplicating a page in WordPress isn’t that hard after all. If you have read this far, you have gotten familiar with all the techniques. But which one is the best for you?

For most users we would recommend using one of our mentioned plugins as this will be the fastest and easiest method. If you don’t plan on duplicating posts and pages on daily basis, you can disable them and enable them only when needed.

If you don’t want to add new plugins to your WordPress installation to declutter your site and maintain quicker loading speeds – you can use our code snippet instead.

Meanwhile, if you plan to duplicate posts or pages only occasionally – copying page content manually could be the best fit for you.

FAQ

Here are answers to some frequently asked questions about duplicating or copying pages and posts on WordPress.

How to copy a custom post type?

Most of what we mentioned in this article applies not only to pages and posts but also to custom post types such as portfolio items and shop products. Follow the steps described in this article to copy a custom post type too.

How to copy and paste a page?

We have created a section Duplicate a Page or Posts Manually, which can be applied to this use case.

Why can’t I copy pages in WordPress?

In this case, we recommend trying out various ways mentioned in this article to see which suits your situation the most.