How to copy a post or a page in WordPress in 5 steps

Categorized as Wordpress

1. Duplicate a Post or a Page manually

Copying a page in WordPress is an easy process. Here are the steps to follow:

1. Log into your WordPress dashboard and select “Pages” from the left menu.

2. From the list of pages, locate and click on the page you want to copy. This will open up its edit screen, where you can make changes to it if needed before copying it over.

3. Once you have made any desired edits click three dots on the right menu and select “Copy all blocks”. That will copy all page content except for the title.

4. Go back to Pages and press Add new button (which brings you to /wp-admin/post-new.php?post_type=page).

5. Write a title for the new page, then place the cursor below the title and press Ctrl+V (Cmd+V on Mac). That will paste all of the content from the page you wanted to clone.

Now you are ready to publish the duplicated page.

2. How to make a copy of post in WordPress using PHP code

This code adds a “Duplicate” link to the actions for each post in the admin panel. When clicked, it creates a new draft post with the same title and content as the original post. The new post can then be edited and published as needed.

Add this to your theme’s functions.php file:

// Enable post duplication function
function wp_admin_duplicate_post() {
  // Check if user has permission to create posts
  if (!current_user_can('create_posts')) return;
  // Check if post type is supported
  if (!isset($_GET['post']) || !isset($_GET['action'])) return;
  // Check if post type is supported
  if ($_GET['action'] != 'duplicate_post') return;
  // Check if post type is supported
  if (get_post_type($_GET['post']) != 'post') return;
  // Get original post object
  $post = get_post($_GET['post']);
  // Create a new post object with the same post data
  $new_post = array(
    'post_title' => $post->post_title,
    'post_content' => $post->post_content,
    'post_status' => 'draft', // Change post status to draft
    'post_type' => 'post', // Post type must be the same as original post
  // Insert the new post into the database
  $new_post_id = wp_insert_post($new_post);
  // Redirect to the edit page for the new post
  wp_redirect(admin_url('post.php?post=' . $new_post_id . '&action=edit'));
add_action('admin_action_duplicate_post', 'wp_admin_duplicate_post');

// Add "Duplicate" link to post actions
function wp_admin_duplicate_post_link($actions, $post) {
  if (current_user_can('create_posts') && $post->post_type == 'post') {
    // Add a "Duplicate" action link
    $actions['duplicate'] = '<a href="' . wp_nonce_url(
      admin_url('admin.php?action=duplicate_post&post=' . $post->ID),
      'duplicate_post_' . $post->ID
    ) . '" title="Duplicate this item" rel="permalink">Duplicate</a>';
  return $actions;
add_filter('post_row_actions', 'wp_admin_duplicate_post_link', 10, 2);

3. Use a Duplicate Post plugin

Duplicate Post is the perfect plugin for quickly and easily duplicating posts, pages, and custom post types. With over 4 million downloads, it’s one of the most popular plugins available

Once you’ve activated Duplicate Post on your WordPress site, a new “Clone” link will be added to each post in the main Posts screen in the WordPress admin area. This makes it easy to create an exact copy of any existing post or page you have created so that you can modify it without affecting the original version. T

his is especially useful if you need to test out changes with different content while still keeping your original intact. With its simple interface and no coding required, Duplicate Post is great for both beginner and experienced users.

Leave a reply

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