[email protected]

How to Duplicate a Page or Post in WordPress 2022

Affiliate disclosure: In full transparency – some of the links on our website are affiliate links, if you use them to make a purchase we will earn a commission at no additional cost for you (none whatsoever!).

In WordPress, duplicating a page or post can involve more than simply copying and pasting the information. You can also maintain the page template, SEO information, and graphics to save time when rebuilding or changing your website’s content.

WordPress makes it simple to duplicate pages, articles, and all their associated data. There are straightforward ways to complete the task, both with and without a plugin.

In this tutorial, we’ll examine how to safely clone a page or post and offer several helpful plugins. Let’s immediately begin!

How to Duplicate a Page or Post in WordPress-Wordpress Home

Easily Clone a Page in WordPress with These Plugins

Using a plugin to clone a page in WordPress is quite straightforward, as everything is handled in the dashboard. Plugins are also the most secure way to duplicate a post or page, as you will not directly edit your site’s code.

Here are four plugins that are worth investigating if you’re looking for the proper tool.

1. Duplicate Post

Duplicate Post

Duplicate Post is one of the most popular WordPress plugins for cloning pages and posts. This plugin is simple to use and duplicates the entire page or post, including the associated comments. It also provides a prefix or suffix option for distinguishing the original post from the clone.

Simply follow the steps below to duplicate a post using this tool:

  • Install the plugin and activate it.
  • When cloning pages or articles, in your WordPress dashboard, navigate to Posts > All for posts or Pages > All for pages.
  • To replicate a page or post, navigate to it and then click the Clone button.
  • Using Bulk Actions, several pages or posts can be selected and cloned simultaneously.

2. Duplicate Page and Post

Duplicate Page or Post

Duplicate Page and Post’s lack of features is compensated for by its quickness. This plugin is one of the quickest ways to duplicate a post or page in WordPress, and it won’t slow down your site with needless features.

To clone a page or post with this plugin, use the following steps:

  • Install the plugin and activate it.
  • Visit Posts > All or Pages > All, depending on the type of content you wish to copy.
  • The desired page or post must be hovered over.
  • Select the Duplicate button.

3. Duplicate Page

Duplicate Post.

Duplicate Page provides several additional capabilities that other cloning plugins lack. This plugin copies posts, pages, and custom post kinds. In addition, the generated copies can be saved as drafts, pending, public, or private.

You can use Duplicate Page by following these steps:

  • The plugin needs to be installed and activated.
  • Make it fit your needs by configuring its settings.
  • Find the content you want to duplicate by going to Pages > All or Posts > All.
  • You can duplicate this by clicking the Duplicate This button.

4. Post Duplicator

Post Duplicator

Post Duplicator is a straightforward cloning plugin. This solution duplicates any post or page exactly, including custom post types, custom fields, and custom taxonomies. It is simple to implement and shouldn’t add much weight to your website.

The steps for duplicating content with this tool are as follows:

  • Install and activate the plugin.
  • Visit Posts > All or Pages > All to locate the content you wish to duplicate.
  • Place your mouse pointer over the post or page.
  • Click the Copy Page or Copy Post option.

Duplicating a Page in WordPress Without a Plugin

WordPress does not require the usage of a plugin to duplicate a page or post. This can also be accomplished manually by editing the functions.php file or by copying and pasting the appropriate code. Let’s examine how each method operates.

1. Enable Cloning via funtions.php Code

One of the manual ways to clone a WordPress page or post is to alter the code in your functions.php file. While this can be easy to perform, you do need to be cautious and make a backup of your website first.

To enable cloning for posts, you’ll need to access your functions.php file and open it for modification, using Secure File Transfer Protocol (FTP) or whatever other method you like. Then you’ll need to add the following code snippet at the end of the file:

 

/*

 * Function for post duplication. Dups appear as drafts. User is redirected to the edit screen

 */

function rd_duplicate_post_as_draft(){

  global $wpdb;

  if (! ( isset( $_GET[‘post’]) || isset( $_POST[‘post’])  || ( isset($_REQUEST[‘action’]) && ‘rd_duplicate_post_as_draft’ == $_REQUEST[‘action’] ) ) ) {

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

  }

  /*

   * Nonce verification

   */

  if ( !isset( $_GET[‘duplicate_nonce’] ) || !wp_verify_nonce( $_GET[‘duplicate_nonce’], basename( __FILE__ ) ) )

    return;

  /*

   * get the original post id

   */

  $post_id = (isset($_GET[‘post’]) ? absint( $_GET[‘post’] ) : absint( $_POST[‘post’] ) );

  /*

   * and all the original post data then

   */

  $post = get_post( $post_id );

  /*

   * if you don’t want current user to be the new post author,

   * then change next couple of lines to this: $new_post_author = $post->post_author;

   */

  $current_user = wp_get_current_user();

  $new_post_author = $current_user->ID;

  /*

   * if post data exists, create the post duplicate

   */

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

    /*

     * new post data array

     */

    $args = array(

      ‘comment_status’ => $post->comment_status,

      ‘ping_status’    => $post->ping_status,

      ‘post_author’    => $new_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,

      ‘post_type’      => $post->post_type,

      ‘to_ping’        => $post->to_ping,

      ‘menu_order’     => $post->menu_order

    );

    /*

     * insert the post by wp_insert_post() function

     */

    $new_post_id = wp_insert_post( $args );

    /*

     * get all current post terms ad set them to the new post draft

     */

    $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array(“category”, “post_tag”);

    foreach ($taxonomies as $taxonomy) {

      $post_terms = wp_get_object_terms($post_id, $taxonomy, array(‘fields’ => ‘slugs’));

      wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);

    }

    /*

     * duplicate all post meta just in two SQL queries

     */

    $post_meta_infos = $wpdb->get_results(“SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id”);

    if (count($post_meta_infos)!=0) {

      $sql_query = “INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) “;

      foreach ($post_meta_infos as $meta_info) {

        $meta_key = $meta_info->meta_key;

        if( $meta_key == ‘_wp_old_slug’ ) continue;

        $meta_value = addslashes($meta_info->meta_value);

        $sql_query_sel[]= “SELECT $new_post_id, ‘$meta_key’, ‘$meta_value'”;

      }

      $sql_query.= implode(” UNION ALL “, $sql_query_sel);

      $wpdb->query($sql_query);

    }

    /*

     * finally, redirect to the edit post screen for the new draft

     */

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

    exit;

  } else {

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

  }

}

add_action( ‘admin_action_rd_duplicate_post_as_draft’, ‘rd_duplicate_post_as_draft’ );

/*

 * Add the duplicate link to action list for post_row_actions

 */

function rd_duplicate_post_link( $actions, $post ) {

  if (current_user_can(‘edit_posts’)) {

    $actions[‘duplicate’] = ‘<a href=”‘ . wp_nonce_url(‘admin.php?action=rd_duplicate_post_as_draft&post=’ . $post->ID, basename(__FILE__), ‘duplicate_nonce’ ) . ‘” title=”Duplicate this item” rel=”permalink”>Duplicate</a>’;

  }

  return $actions;

}

add_filter( ‘post_row_actions’, ‘rd_duplicate_post_link’, 10, 2 );

To enable cloning for pages as well, use the same code but replace the final line with:

add_filter(‘page_row_actions’, ‘rd_duplicate_post_link’, 10, 2);

The file can then be saved and re uploaded to the server. Following that, you will be able to access your WordPress dashboard. When you hover over a page or post to duplicate, the Duplicate button should now display..

2. Manually Copy & Paste Code to Duplicate a Page

If you do not wish to modify your functions.php file, you can manually copy and paste the code for the desired page or post. To accomplish this, you’ll need to:

  • Open the page or post that you wish to copy.
  • Select Additional Tools & Options from the menu.
  • Select Code Editor.
  • Copy the page or post’s source code.
  • Select New Page or New Post.
  • Open up the Code Editor in the new post or page.
  • Insert the code.
  • Select Additional Tools & Options from the menu.
  • Select Visual Editor.
  • The new page or post must now be an exact copy of the previous one.

This process might be time-consuming, and you must repeat it for each page or post you wish to replicate. I recommend using a plugin if you wish to duplicate a great deal of information.

Quick Links:

Conclusion How to Duplicate a Page or Post in WordPress 2022

Cloned pages make it easier to streamline your WordPress experience. There are numerous other techniques to save time, including transferring development environments and migrating pages or posts between WordPress sites.

Only the code coming in copyscape 

Sonia Allan

Sonia Allen has been a freelance content writer and a senior SEO and content marketing analyst at Digiexe, a digital marketing marketing agency specializing in content and data-driven SEO. She has more than seven years of experience in internet marketing & affiliate marketing. She likes sharing her knowledge in a wide range of domains ranging from ecommerce, startups, social media marketing, make money online, affiliate marketing to human capital management, and much more. She has been writing for several authoritative SEO, Make Money Online & digital marketing blogs on these authority websites like : Designskew.com, Crazythemes.com, Oldgeekjobs.com, Digiexe.com,Need4Hosting.info.

Leave a Comment