How to duplicate a page in WordPress?


How to duplicate a page in WordPress 2

So, do you want to duplicate a post or a page in WordPress? Duplicating a page in WordPress is more than just copying and pasting the page contents. If you want all of your page contents, formatting, and other settings to be copied to another page, duplicating is the best way to do it.

Building, managing and scaling your website can be challenging. Hire the right experts to do your job. Contact our North Sydney Website Designers.

WordPress does not come with the feature to duplicate pages by itself but you can add the feature by editing the code on the Functions PHP file or by adding a plugin.

Manually copying only works for web page contents and other settings like SEO, page attributes, and tags are not copied. So, you will need to update other settings manually. This also means that there are chances for errors and small mistakes. Also, this is not practical for managing large websites in terms of time and effort. Luckily, there are easy ways in WordPress to duplicate pages and posts.

Table of Contents

But, how do you duplicate a page in WordPress? Well, there are a few ways to duplicate a WordPress page.

  • Use a duplicate WordPress pages plugin.
  • Add a code snippet to the ‘functions.php’ file on your Theme editor.
  • Copy the HTML code from the page and paste it into the new page.

We will go step by step for each of these ways.

Whatever the reason, duplicating pages in WordPress is crucial when it comes to running or even building a WordPress website. We will dive deep into the easy ways to duplicate WordPress pages or posts.

Duplicate WordPress Pages or Posts with Plugin

Duplicating a page or post using a WordPress plugin is the easiest method. You can install and activate the plugin and use it to duplicate a page or post.

First, you will need to download a duplicate post or page plugin. Download any of the following plugins to do this.

You may also search for other duplicate posts plugins as shown below in the WordPress plugin store.

Make sure to check for updates, support, version compatibility, and reviews before using any plugin.

ee041ebb 962a 45ca a582 c520a79d6042

Download the plugin, upload it from WordPress Dashboard > Plugins > Add New > Upload, Install and Activate the plugin.

Add new plugin wordpress

Alternatively, you can go to WordPress Dashboard > Plugins and search for the plugin. Then, install the plugin and activate it.

install yoast duplicate page plugin

After installing the plugin, follow these steps:

Step 1: Log in to your WordPress Dashboard.

Step 2: Click on the Pages or Posts tab on the left panel of your WordPress Dashboard.

Duplicate page or posts

Step 3: Hover over the page or post you want to duplicate.

Step 4: Click on Duplicate or Clone.

Clone page WordPress

Step 5: Make any necessary changes and click publish to get it live on your website.

Note: You may see either a Duplicate or Clone option depending on the plugin you installed.

That is all you need to duplicate a page or post in WordPress using plugins with all the settings and layouts.

Keep in mind that you may need to update links to your new page and new page URL after duplicating a new page or post. You will still need to make small changes like page URLs, internal links, and others as required.

Duplicating WordPress Page or Post Without Plugins

There are a couple of ways to clone your WordPress page or post without using plugins. One of them is simply copying the page contents and another is by editing the functions.php file of your WordPress theme.

Let’s have a closer look at these methods.

Duplicating a Post by copying HTML code

  1. Log into your WordPress Dashboard
  2. Go to the page or post list.
  3. Hover over the post/page.
  4. Click on edit.
  5. Select the Code Editor option (or press CTRL+ALT+SHIFT+M).
  6. Copy all the page codes.
  7. Paste the code to the new page or post.
  8. Publish the new page or post.

Here are a few screenshots for the above process.

edit page wordpress
Edit a page WordPress
Visual code editor wordpress
Code edtor wordpress
View of Code Editor in WordPress

Duplicate a post or page in WordPress by editing the functions.php file

You can also duplicate WordPress Pages or Posts without using the plugins. For this, you will need to edit the WordPress functions.php file.

This method is best for advanced users as errors in the theme files may break your website. Do not forget to back up your site in case anything breaks or malfunctions.

Follow these steps to enable ‘Duplicate’ options on your WordPress Pages and Posts.

Step 1: Log into WP-admin.

Step 2: Go to Appearance > Theme File Editor.

Appearance theme file editor

Step 3: Select the functions.php file from the right sidebar.

Theme file editor functions php wordpress
WordPress Theme Editor – functions.php file

Step 4: Add the following lines of code to the functions.php file.

function duplicate_page() {

global $wpdb;

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

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

}

/*

* 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

After you have pasted the above lines of code, you will see the ‘Duplicate’ option on your WordPress pages as shown below.

You may also use the inbuilt file editor or other editor WordPress plugins to do this.

Conclusion

There are instances where you might want to duplicate your WordPress page. It may be a well-performing page and you might want your new page to be similar. Duplicating a page definitely saves you a lot of time whether you do it manually or with the help of a duplicate post plugin.

Rather than creating and working on a new page each time, you might find it easier to duplicate pages and make a few changes. This is especially true when the pages are similar, like service pages or even when designing eCommerce website pages.

Make sure to create a backup of your WordPress site before making changes to your website, especially when editing the core theme files. Here is our recommended list of backup plugins for WordPress based on popularity and reviews.

People Also Asked

Can you duplicate a page in WordPress without a plugin?

Yes, you can duplicate a page in WordPress without a plugin. There are a couple of ways to do this. Either you can add a code snippet to your ‘functions.php’ file to enable the ‘Duplicate’ option for your pages or posts. Or, you can also copy all the page contents from the Code Editor screen and paste it into the new page or post.

How do I make changes to a duplicated page in WordPress?

Making changes to the duplicated pages in WordPress is no different than editing a new page or post. While duplicating a page or a post, you must be careful to make changes to the URL and internal links coming to the new page.

The original page or post is not affected when you duplicate a page. However, there are similar options to duplicating the page like “Rewrite and Republish” that come with some plugins and this may make changes to the original page.

Can I duplicate a post as well as a page in WordPress?

Yes, you can duplicate both pages and posts in WordPress. After you have used the plugin or made changes to the functions.php file, Go to the Page or Post tab on your dashboard and hover over the Page/post you want to duplicate, and click on duplicate to duplicate the page/posts.

Is there a difference between duplicating a page and copying a page in WordPress?

Yes, copying a page is different from duplicating a page in WordPress. When you copy a page in WordPress, only the contents and the visual elements will mostly be copied. However, when you duplicate a page, all the contents on the page along with the settings and layouts will be copied to the new page.

Will comments and media also be copied when I duplicate a page in WordPress?

Yes, the comments and the media will also be copied while duplicating a WordPress page.

Are there any limitations to the number of times I can duplicate a page in WordPress?

No, there is no practical limit to the number of times you can duplicate a page in WordPress. There are rumors that the limit is 1 billion times, but that is not practical.

Are there any SEO implications of duplicating a page in WordPress?

Yes, there are a few SEO concerns you should keep in mind while duplicating a page in WordPress. For example, duplicate content on the website may hurt your Google rankings. This also might mean issues in indexing you may want to fix.


Updated on: 17 January 2023 |


Sazjan Neupane

Sazjan Neupane

Sazjan helps us reach our dream clients with his expertise in Search Engine Optimisation, PPC, Project Management & Online Business Development. He has worked with a variety of clients in different industries over the last 5 years. In his free time, Sazjan enjoys traveling and exploring new cultures.