Categories

Select a Child Category
category
6681d1d9108c4
0
0
Loading....

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Category:Website Design & Development

How to duplicate a page in WordPress in 2024

Written by

netizenstech
Spread the love

Welcome to our step-by-step tutorial on how to duplicate a page in WordPress like a pro. Duplicating pages can be a time-saving technique for website owners, enabling them to create similar content quickly without starting from scratch each time. 

Netizens technologies help you to provide services that help you grow your business with WordPress Website Design, WordPress Theme Development, Custom WordPress Development, PSD To WordPress Conversion, Custom WordPress Plugin Development, WordPress Website Support, WordPress Update Service, WordPress WooCommerce Theme, WordPress Migration Service, WordPress API Integration Service, WordPress Payment Solution and also provide other services like UI/UX Design, Mobile App Development, Front-End Development, Back-End Development, SEO & Digital, Marketing, Quality Assurance, Customer Support. 

Whether you need to create multiple landing pages, product pages, or blog templates, learning how to duplicate a page in WordPress will save you valuable time and effort. Using clear and easy-to-follow directions, we’re going to guide you through extracting a page for your WordPress website in this guide. 

After reading this tutorial, you should have all the necessary information to duplicate pages and increase efficiency quickly.

Introduction: 

As everyone is aware, WordPress is a very useful tool for creating websites. You can upload documents, manage photographs, write articles—more often known as blogs or blog posts—and much more. Over time, what began as a blogging platform has developed into the preferred content management system (CMS) for over one-third of the internet. 

Even with all of WordPress’s features, you cannot copy a post or page right out of the box. Although it appears to be a small error, it is one that we can correct. We’ll cover three simple methods in this article for duplicating a page in WordPress.

Understanding the Purpose to duplicate a page in WordPress:

Duplicating a page is an easy way to test layouts, make variations for A/B testing, and accelerate content revisions. It promotes data-driven decision-making, allowing for the testing of several designs without interfering with the live version, and simplifies content changes for websites with a lot of material. Duplicating pages makes it possible to provide variations to various audience segments, which improves analysis and helps content strategies be refined.

How to Duplicate a Page or Post in WordPress:

In WordPress, duplicating a page or post involves more than just copying and pasting the information. When updating your website or improving your content, you can also save time by keeping the page template, SEO data, and graphics.

Fortunately, WordPress makes it simple to duplicate pages, posts, and all of the data that goes with them. With or without a plugin, there are easy ways to complete the task. 

This tutorial will discuss how to safely generate a duplicate WordPress page or post and introduce a few useful plugins. Now let’s get started!

Duplicate a Page in WordPress with These Plugins:

  1. Duplicate post:

Duplicate Post is a popular choice for replicating WordPress pages and posts. This well-liked plugin is simple to use and copies everything material, including comments and page or post content. To differentiate between your original post and the clone, it also provides a prefix or suffix choice.

To duplicate a WordPress post with this tool, you just need to:

  • Install and activate the plugin.
  • In your WordPress dashboard, go to Posts > All when cloning posts, or Pages > All when cloning pages.
  • Navigate to the original page or post you want to copy, and click on Clone to duplicate it.
  • Multiple pages or posts can be selected, and you can clone them all at once using Bulk Actions.
  1. Duplicate page and post:

While lacking in functionality, Duplicate Page and posts more than makes up for it in speed. One of the quickest methods to replicate a post or page in WordPress is with this small duplicate post plugin, which won’t slow down your website with extra features.

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

  • Install and activate the plugin.
  • Go to Posts > All or Pages > All, depending on what you want to duplicate.
  • Hover over the page or post you want to clone.
  • Click on the Duplicate option.
  1. Post Duplicator:

Another simple cloning plugin is Post Duplicator. This solution creates an exact duplicate of any post or page, including custom post types, custom fields, and custom taxonomies. It’s quick and easy to use, and shouldn’t add much weight to your site.

To duplicate content with this tool, follow these steps:

  • Install the plugin and activate it.
  • Navigate to Posts > All or Pages > All to find the content you want to clone.
  • Hover over the post or page.
  • Click on the Duplicate Page or Duplicate Post option.

Duplicating a Page in WordPress Without a Plugin:

1. Enable Cloning via funtions.php Code

You can manually copy a WordPress page or post by editing the functions.php file’s code. Even though it can be simple to accomplish, you should exercise caution and first create a backup of your website. 

You must access your functions.php file and open it for editing via Secure File Transfer Protocol (FTP) or another method of your choice to allow cloning for posts. Then you’ll need to add the following code snippet to 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);

2. Manually Copy & Paste Code to Duplicate a Page

If you do not want to edit your functions.php file, you can manually copy and paste the code for the page or post you want to clone. To do this, you will need to:

  • Open the page or post you want to duplicate.
  • Click on the More Tools & Options menu.
  • Select Code Editor.
  • Copy the code for the page or post.
  • Click on New Post or New Page.
  • In the new post or page, open the Code Editor.
  • Paste in the code.
  • Click on the More Tools & Options menu.
  • Select Visual Editor.
  • The new page or post should now be a clone of the old one.

It may require some time to complete this process, and you must do it separately for every page or post that you wish to duplicate. For this reason, if you want to duplicate a lot of information, we suggest using a WordPress duplicate page plugin.

Conclusion:

We have covered the entire process of copying a WordPress page step-by-step in this extensive guide. The primary conclusion we want you to remember is to duplicate the pages in WordPress and have a backup of your website. You may expedite the process of developing a website and save a significant amount of time by taking advantage of page duplication. Gaining proficiency in WordPress page duplication will not only improve efficiency but also open up new avenues for experimentation and creativity. Whether you choose the increased functionality of plugins or the ease of use of built-in capabilities, mastering the art of page duplication is a crucial ability that may improve the management of your website.

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Author Logo

Written by

netizenstech

Related Blog & Articles

Zendrop

Zendrop Dropshipping Strategies for Growth in 2024

Location Reload Method | javascript:location.reload(true)

tiktok-coins

TikTok Coins: Unlocking the Currency of Creativity