How to Clone a Post, Page, or Custom Post Type in WordPress

Duplicating posts, pages, or custom post types in WordPress can be useful for various reasons—whether you’re creating similar content, testing layouts, or making quick updates without affecting the original. There are multiple ways to achieve this, including free plugins, custom code, and a manual approach. In this article, we’ll explore each option to clone a post, page or any custom post type.


1. Using Free Plugins (Recommended for Most Users)

The easiest way to clone a post in WordPress is by using a plugin. Here are some popular free options:

a) Duplicate Post by Yoast

This plugin allows you to duplicate posts, pages, and custom post types with a single click.

Features:

  • One-click duplication from the post list
  • Works with posts, pages, and custom post types
  • Bulk duplication option
  • Customizable settings for what gets copied

🔗 Download Duplicate Post

b) Duplicate Page and Post

A simple, lightweight plugin for duplicating posts and pages.

Features:

  • Adds a “Duplicate” link in post/page lists
  • Works with posts, pages, and some custom post types
  • No additional settings required

🔗 Download Duplicate Page and Post

c) Post Duplicator

This plugin allows you to create an exact duplicate of any post, including custom post types.

Features:

  • Preserves all post meta, taxonomies, and settings
  • Supports custom post types
  • No configuration required

🔗 Download Post Duplicator


2. Cloning a Post Using Custom Code (For Developers)

If you prefer not to use a plugin, you can achieve the same functionality with custom code. Add the following snippet to your functions.php file in your theme or child theme:

Step 1: Add a Duplicate Link in Post List

function imi_duplicate_post_link($actions, $post) {
    if (current_user_can('edit_posts')) {
        $actions['duplicate'] = '<a href="' . wp_nonce_url(admin_url('admin.php?action=imi_duplicate_post&post=' . $post->ID), 'imi_duplicate_post_nonce', '_wpnonce') . '">Duplicate</a>';
    }
    return $actions;
}
add_filter('post_row_actions', 'imi_duplicate_post_link', 10, 2);
add_filter('page_row_actions', 'imi_duplicate_post_link', 10, 2);

Step 2: Create the Duplicate Function

function imi_duplicate_post() {
    if (!isset($_GET['post']) || !current_user_can('edit_posts')) {
        wp_die('Unauthorized request.');
    }

    $post_id = absint($_GET['post']);
    $post = get_post($post_id);

    if (!$post) {
        wp_die('Post not found.');
    }

    $new_post = array(
        'post_title'    => $post->post_title . ' (Copy)',
        'post_content'  => $post->post_content,
        'post_status'   => 'draft',
        'post_type'     => $post->post_type,
        'post_author'   => get_current_user_id(),
    );

    $new_post_id = wp_insert_post($new_post);

    if ($new_post_id) {
        // Copy post meta
        $meta_keys = get_post_meta($post_id);
        foreach ($meta_keys as $key => $values) {
            foreach ($values as $value) {
                add_post_meta($new_post_id, $key, maybe_unserialize($value));
            }
        }

        // Redirect to edit screen
        wp_redirect(admin_url('post.php?action=edit&post=' . $new_post_id));
        exit;
    }
}
add_action('admin_action_imi_duplicate_post', 'imi_duplicate_post');

This code adds a “Duplicate” link to the post/page list and creates an exact duplicate with all metadata.


3. Manually Duplicating a Post (For Those Who Prefer No Plugins or Code)

If you don’t want to use plugins or custom code, you can manually duplicate a post in the WordPress editor.

Step 1: Open the Post/Page You Want to Duplicate

  • Navigate to PostsAll Posts (or Pages → All Pages).
  • Click Edit on the post/page you want to clone.

Step 2: Copy the Content

  • In the editor, switch to Text Mode (for Classic Editor) or select all blocks (for Gutenberg).
  • Copy the entire content.

Step 3: Create a New Post

  • Go to PostsAdd New (or Pages → Add New).
  • Paste the copied content into the new post.
  • Manually copy categories, tags, featured image, and other settings.

Step 4: Save as Draft or Publish

Once everything is set, click Save Draft or Publish.

🔹 This method is best for one-time duplication but is inefficient for bulk cloning.


Final Thoughts

Duplicating posts in WordPress can be done in various ways. If you need a quick and efficient method, using a plugin like Duplicate Post is the easiest solution. Developers who prefer code can use the custom PHP function, while those who rarely need to duplicate posts can do it manually.

Best for Beginners: Use a plugin
Best for Developers: Custom PHP function
Best for Occasional Use: Manual copy-paste

Which method do you prefer? Let us know in the comments!

Leave a Reply

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