Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.

Gallery

Contacts

411 University St, Seattle, USA

engitech@oceanthemes.net

+1 -800-456-478-23

WordPress
How to Duplicate Pages in WordPress

Do you want to paste or duplicate the existing data for reuse? If this is the reason for copying pages in WordPress, you might be looking for the best and easiest ways to do this process. Before that, let me tell you that WordPress is a platform for businessmen and content creators. So, there are chances where people decide to add a new post by just editing their previous posts. This process can be done by duplicating.

Other than this, there is more than duplicating or pasting; you can retain page templates, images, SEO data to save them for the future.

Therefore, if you are among those who have decided to clone the page, know how to duplicate pages in WordPress by uncomplicated steps. Following the procedure discussed in the article will save you time and effort. So, let’s get started.

Why is there a Need to Duplicate Pages in WordPress?

Now that you have decided to duplicate pages but do you know the actual reason behind this process? Why is it required? Below I have listed some fundamental reasons that urge businessmen to do this procedure.

  • There are chances that you have found a new layout for your page.
  • You want to use CSS code or custom HTML in your new layout.
  • You want to update your page by editing the drafts.

How to Duplicate a Page in WordPress?

Technology is getting advanced day by day, and we cannot say that a process is done with just one source. There are multiple options to do a single task. Same is the case here, to duplicate pages in WordPress, there are several steps such as:

  • With plugins
  • Without plugins, through code, etc.

Let’s see those strands one by one. To make it more comprehensible, these threads are described most thoroughly. So that you can complete this task efficiently and hassle-free.

Duplicating a Page Through WordPress Plugin

Before considering plugins, you might be thinking of doing this procedure manually. But do you know what will happen when you do this? By duplicating any page or post, you might face many issues like:

  • The overall process takes longer, and you might get frustrated.
  • Instead of duplicating your page, your whole images, words, SEO content, and links displayed on the page will be copied. It will affect your search in the market.

Hence, many plugins are used for this process. These plugins are famous for a reason as they make tasks more accessible and minor threats. So, let‘s see what are those significant plugins that can take your burden off while cloning pages.

Duplicate Post Plugin

Duplicate Post plugin

The first and most famous plugin from Yoast is a duplicate plugin. The best part of this plugin is that it duplicates comments, slug, or menu orders by allowing you to differentiate through suffixes and prefixes. It means that when you copy a word from the original file, you can add suffixes or prefixes to distinguish between actual and simulated files. Fascinating, right?

Now see the overall process about how to copy a page in WordPress through this plugin.

  • “install” and “activate” the plugin.
  • Go to the WordPress dashboard and click on “pages” choose “all pages.”
  • After picking, you will see the option “clone” and “new draft.”

Duplicate Post Plugin

  • Press on “clone,” and you are done here.

Duplicate Page or Post

Duplicate Page and Post Plugin

This plugin is able to duplicate any page or post without altering its title, style, or content type. The most appealing thing about this plugin is that it is easier to use than others. So, follow the steps discussed below and know about its functions:

  • “install” and “activate” plugin.
  • Go to “all pages” and choose what you want to duplicate.

Duplicate Page and Post Plugin

  • Press “duplicate” the clone file will be shown in front of you with the same style and name.

Post-Duplicator

post Duplicator plugin

This plugin allows you to retain custom files and taxonomies along with the same style and content type.

Here is how you can utilize this plugin to duplicate pages:

  • After “installing and activation,” access your WordPress admin to locate pages you want to clone.
  • Go to “tools” and choose “post duplicator” to set some settings before duplicating pages.
  • Set the status on the page “published/draft/same as the original.”
  • After choosing, click on “duplicate page.”

Duplicating Page Without Plugins

Besides using plugins, there are different ways to duplicate pages, such as code in the functions.php file. Hence, you can opt for WordPress built-in file editors, HTML editors, or FTP clients to activate the duplication link. Choosing all these options at once might baffle you, so see how you can do this process using the function.php file.

Duplicate without Plugin

Duplicate Pages Through Function.Php File

To duplicate a post on WordPress website, you’ll need to paste the following code snippet in your functions.php 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 );
  • Once you have successfully embedded the code above, Locate the “duplicate” button in the “all pages/ all post.”
  • Press “duplicate” and done.

Manually Duplicate Pages in WordPress

Although this process is daunting, knowing about all aspects is worth it, as they can aid in the future. So, here are a few threads that you have to follow to clone pages in WordPress manually.

  • Go to the page you want to duplicate and “more tools and options” from the menu.
  • Choose “code editor” and copy the code.
  • Press on “new page/ new post” and open the “code editor” on a new page.
  • Paste the code here and press on “more tools and options” and “visual editor.”
  • Once you are done, you will see the clone on the old page.

Final Words

WordPress is an ideal platform for businessmen, but this can be hectic when you have to make new posts and pages in a short time. But not more now, WordPress has come up with a unique feature of duplicating pages. Know how you can do this process in simple steps. It will help you a lot in saving your time and effort. So, now pay heed to other tasks by completing this one is one-go. If you need any Kind of WordPress services You can Hire US.

Leave a comment

Your email address will not be published.