Cloud Service >> Knowledgebase >> WordPress >> Discover the Steps to Duplicate WordPress Pages or Posts
submit query

Cut Hosting Costs! Submit Query Today!

Discover the Steps to Duplicate WordPress Pages or Posts

Duplicating WordPress pages or posts can be useful when you want to create a similar page or post without starting from scratch. Here are different methods to duplicate WordPress pages or posts:

Method 1: Using a Plugin

The easiest and most common way to duplicate pages or posts in WordPress using a plugin. There are several plugins available for this purpose, but "Duplicate Post" (now part of the "Yoast Duplicate Post" plugin) is one of the most popular.

Steps:

1. Install the Plugin:

Go to your WordPress admin dashboard.

Navigate to Plugins > Add New.

Search for "Yoast Duplicate Post.

Click Install Now and then Activate.

2. Configure Plugin Settings (Optional):

After activation, go to Settings > Duplicate Post.

You can configure which elements to copy (e.g., title, content, date, status) and where the duplicated post/page should be redirected.

3. Duplicate a Post or Page:

Go to Posts or Pages in your WordPress dashboard.

Hover over the post or page you want to duplicate.

You will see new options: Clone or New Draft.

Clone: This creates a duplicate of the post/page without opening it in the editor.

New Draft: This duplicates the post/page and opens it in the editor, allowing you to make changes before publishing.

4. Edit the Duplicated Post/Page:

If you chose New Draft, the duplicated post/page will open in the editor. Make any necessary changes.

Publish the post/page when you're ready.

Method 2: Manually Duplicating Content

If you prefer not to use a plugin, you can manually duplicate a page or post by copying the content.

Steps:

1. Open the Original Post/Page:

Go to the Posts or Pages section in your WordPress dashboard.

Open the post/page you want to duplicate.

2. Copy the Content:

In the editor, switch to the Text (HTML) tab (if you're using the Classic Editor) or Code Editor (if you're using the Block Editor/Gutenberg).

Copy all the content from the editor.

3. Create a New Post/Page:

Go to Posts > Add New or Pages > Add New.

Paste the copied content into the new post/page.

4. Adjust and Publish:

Modify the title, content, and other settings as needed.

Publish the duplicated post/page.

Method 3: Using the Block Editor (Gutenberg)

If you're using the Block Editor (Gutenberg), you can copy and paste individual blocks or entire groups of blocks from one post/page to another.

Steps:

1. Copy Blocks:

Open the post/page in the Block Editor.

Click on a block or group of blocks.

Use the options menu (three vertical dots) and select Copy.

2. Paste into a New Post/Page:

Create a new post/page.

Paste the copied blocks into the editor.

3. Adjust and Publish:

Make any necessary adjustments.

Publish the duplicated content.

Method 4: Using Custom Code (Advanced Users)

For developers or advanced users, you can duplicate a post or page programmatically by adding custom code to your theme's functions.php file or by creating a custom plugin.

Example Code:

php

Copy code

function duplicate_post_as_draft() {

    global $wpdb;

    if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {

        wp_die('No post to duplicate has been supplied!');

    }

 

    // Get the original post ID

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

    $post = get_post($post_id);

 

    // Copy the post and set its status to draft

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

        $new_post = array(

            'post_title' => $post->post_title,

            'post_content' => $post->post_content,

            'post_status' => 'draft',

            'post_author' => $post->post_author,

            'post_type' => $post->post_type

        );

        $new_post_id = wp_insert_post($new_post);

 

        // Copy the taxonomies, metadata, etc.

        $taxonomies = get_object_taxonomies($post->post_type);

        foreach ($taxonomies as $taxonomy) {

            $post_terms = wp_get_object_terms($post_id, $taxonomy);

            foreach ($post_terms as $term) {

                wp_set_object_terms($new_post_id, $term->slug, $taxonomy, true);

            }

        }

 

        $post_meta = get_post_meta($post_id);

        foreach ($post_meta as $key => $values) {

            foreach ($values as $value) {

                update_post_meta($new_post_id, $key, $value);

            }

        }

 

        // Redirect to the edit screen of the new draft

        wp_redirect(admin_url('post.php?action=edit&post=' . $new_post_id));

        exit;

    } else {

        wp_die('Post duplication failed, could not find original post: ' . $post_id);

    }

}

add_action('admin_action_duplicate_post_as_draft', 'duplicate_post_as_draft');

 

function duplicate_post_link($actions, $post) {

    if (current_user_can('edit_posts')) {

       $actions['duplicate'] = '

    }

    return $actions;

}

 

This code snippet adds a "Duplicate" link to the post/page row actions in the WordPress theme panel.

Final Steps: Testing and Adjustments

After duplicating the content, review the duplicated post or page to ensure all elements (images, links, SEO settings, etc.) are correctly duplicated.

Adjust the content as needed before publishing.

These methods will allow you to duplicate WordPress pages or posts efficiently, depending on your needs and technical expertise.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!