How to Duplicate a Page in WordPress

3 minutes read

Duplicating a page in WordPress can be done in multiple ways, depending on whether you want to use a plugin or do it manually. Here are the easiest methods:

Method 1: Using a Plugin (Recommended)

Using a plugin simplifies the process and ensures that everything, including metadata and page settings, is copied.

1. Install a Plugin

  • Go to your WordPress Dashboard.
  • Navigate to Plugins > Add New.
  • Search for a plugin like:
    • Duplicate Page
    • Yoast Duplicate Post
    • Duplicate Page and Post
  • Click Install Now and then Activate.

2. Duplicate the Page

  • Go to Pages > All Pages.
  • Find the page you want to duplicate.
  • Click Duplicate or Clone (depending on the plugin).
  • A new draft copy of the page will appear in your pages list.

Method 2: Manually Copy and Paste

If you prefer not to use a plugin, you can copy the content manually.

1. Open the Page

  • Go to Pages > All Pages.
  • Click Edit on the page you want to duplicate.

2. Copy the Content

  • Select all the content (Ctrl + A or Cmd + A).
  • Copy it (Ctrl + C or Cmd + C).

3. Create a New Page

  • Go to Pages > Add New.
  • Paste the content (Ctrl + V or Cmd + V).
  • Adjust settings, title, and permalink as needed.

Method 3: Duplicate via Functions.php (For Developers)

If you are comfortable with code, you can add a duplication function to your theme.

1. Add This Code to functions.php

Go to Appearance > Theme Editor and open functions.php. Add this snippet:

php
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!');
}
$post_id = (isset($_GET[‘post’]) ? absint($_GET[‘post’]) : absint($_POST[‘post’]));
$post = get_post($post_id);

if (isset($post) && $post != null) {
$args = array(
‘comment_status’ => $post->comment_status,
‘ping_status’ => $post->ping_status,
‘post_author’ => $post->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 . ‘ (Copy)’,
‘post_type’ => $post->post_type,
‘to_ping’ => $post->to_ping,
‘menu_order’ => $post->menu_order
);

$new_post_id = wp_insert_post($args);
$post_meta = get_post_meta($post_id);

foreach ($post_meta as $key => $values) {
foreach ($values as $value) {
add_post_meta($new_post_id, $key, maybe_unserialize($value));
}
}

wp_redirect(admin_url(‘edit.php?post_type=’ . $post->post_type));
exit;
} else {
wp_die(‘Post duplication failed.’);
}
}
add_action(‘admin_action_duplicate_post_as_draft’, ‘duplicate_post_as_draft’);

2. Add a Duplicate Button

Add this to functions.php to display a “Duplicate” link:

php
function duplicate_post_link($actions, $post) {
if (current_user_can('edit_posts')) {
$actions['duplicate'] = '<a href="' . wp_nonce_url(admin_url('admin.php?action=duplicate_post_as_draft&post=' . $post->ID), basename(__FILE__), 'duplicate_nonce') . '" title="Duplicate this item">Duplicate</a>';
}
return $actions;
}
add_filter('post_row_actions', 'duplicate_post_link', 10, 2);

Now, a “Duplicate” link will appear under each post or page.


Which Method Should You Use?

  • For beginners: Use a plugin (Method 1).
  • For occasional use: Copy-paste content manually (Method 2).
  • For advanced users: Add custom PHP code (Method 3).
Share it :

Leave a Reply

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