How to Duplicate a Page in WordPress
/ / How to Duplicate a Page in WordPress

How to Duplicate a Page in WordPress

Some of the links in this post are affiliate links. This means if you click on the link and purchase the item, We will receive an affiliate commission at no extra cost to you. All opinions remain our own.

Duplicate content isn’t one thing you need to typically have on your site. However, creating copies of your pages – i.e. duplicating them – for consistency is a sensible apply. Your sole concern needs to be the best way to get the job completed.

Fortunately, there are a few methods to duplicate a page in WordPress, which is to be expected for such a versatile platform. What’s extra, there’s a technique to swimsuit, regardless of your experience.

In this publish, we’ll take a look at 4 methods to duplicate a page in WordPress. However, earlier than this, let’s dig into why you’d need to accomplish that in the primary place.

The Difference Between Duplicating a Page in WordPress and ‘Duplicate Content’

Before we get into particular reasoning, it’s price discussing the distinction between duplicating a page in WordPress, and duplicate content.

The latter pertains to Search Engine Optimization (SEO). Duplicate content means a lot or all of the content on one page on your site is precisely identical to one other elsewhere on the web. While it can be unfavorable, it’s not one thing a search engine will often punish you for immediately.

However, this is completely different from ‘copied content’, which is an express try and ‘game’ the search engines and rank increased. The penalties for this are rather more extreme because the implication is that it’s a deliberate act.

In distinction to all of the above, duplicating your page merely means repeating the formatting, construction, format, and content. The thought is to make use of this duplicated page as a basis for a contemporary one and carries no SEO penalty if used for this reason. Let’s speak a little about why you’d need to do that subsequent.

Why You’d Want to Duplicate a Page in WordPress

Admittedly, you’ll probably know if you’re in a scenario that requires you to duplicate a page in WordPress. However, it might be that your present strategies of creating posts and pages would profit from an extra environment-friendly strategy. For instance:

  • You have a particular format in thoughts on your present page that’s discovered elsewhere on your site.
  • You could create ‘drafts’ of pages that you simply typically reuse when creating new content (for instance, blog posts).
  • There is customized HTML or CSS code discovered in one format that you simply need to use on a new page.
  • You would possibly need to work on a new model of a page, and don’t have staging performance out there for you (though there are higher methods to do that).

All of these conditions would profit from a shortcut in phrases of duplicating your page. As such, let’s sort out the options we advocate in the following part.

How to Duplicate a Page in WordPress (4 Methods)

For the 4 strategies under, we’ll go from comparatively straightforward to reasonably troublesome relying on your experience. Here’s what we’ll cowl:

  1. How to copy and paste your content manually (and why you shouldn’t).
  2. Use the Block Editor to repeat your content.
  3. Install a plugin to duplicate a page.
  4. Add code to your functions.php file to duplicate pages.

Once we’re completed, we’ll then offer you some recommendations for selecting the best method to duplicate a page in WordPress.

1. Copy and Paste Your Content Manually (And Why It’s Not Ideal)

First off, let’s focus on the standard strategy many will take. The ‘brute force’ tactic to duplicating a page in WordPress is to easily copy the content and paste it into a new draft.

If you’re shrugging on the page whereas reading this, we’ll wager you’re in one of the next camps:

  • Your site has few pages and makes use of little SEO or taxonomy fields.
  • The page you’d prefer to duplicate is not accessible by the again finish of your site.
  • You haven’t found a faster means.

If you agree with both of the primary two factors, copying and pasting are going to arguably be the best method to proceed.

However, whereas manually copying and pasting is easy to know and execute, there are a few drawbacks. This strategy gained’t accurately copy over images, classes, and tags, meta descriptions, permalinks, or any under-the-hood parts of your site reminiscent of customized HTML.

Step 1. Copy the Text From the Original Article

CTRL-A is your pal right here, and the steps aren’t advanced both:

  1. Access the site in query.
  2. Highlight and duplicate the textual content.
  3. Paste it into your new draft.

This needs to be simple for even essentially the most ‘tech-deaf’. However, the following step is barely extra tough.

Step 2. Remove Tags From Your HTML

Note that relying on your supply and goal drafts, you could re-apply heading codecs and in addition, take away superfluous HTML from the again finish. To do that, enter the code editor of your page when you’ve copied the content over. Classic Editor users ought to click on the Text tab…

…and Block Editor users will need to head to the Code editor:

The Block Editor's Code editor screen.

From right here, it’s smart to take away any   or tags you discover. Our recommendation is to take a look at a non-duplicated page and observe the construction and format of the code.

Given the work, it may develop into a time sink for a couple of or two pages, and each handbook duplication has the potential to introduce errors and errors.

Instead, it’s higher to contemplate one other of the choices in this record if you wish to effectively duplicate a page in WordPress without errors and losing time.

2. Consider Using the Block Editor’s Functionality to Help You Duplicate Pages

Using the Block Editor to duplicate a page in WordPress is extra of a ‘semi-manual strategy, given that the majority of the drawbacks are nonetheless legitimate.

However, when you have a page inside your individual WordPress site that you simply prefer to duplicate, open the page, and look to the More instruments & choices menu in the highest right-hand nook of the display screen:

The More tools button in WordPress.

Once you open this menu, transfer to the Tools part, and click on Copy all content. From right here, you possibly can paste the content into a contemporary draft and start to work on it. However, it’s nonetheless not essentially the most environment-friendly method to duplicate a page in WordPress.

3. Use a WordPress Plugin to Duplicate Your Page

Practically every little thing inside WordPress may be achieved utilizing a plugin, and duplicating pages is no exception.

Your first job right here is to decide on one thing appropriate. You’ll need to take a look at plugins that were up to date inside the final six months, work along with your model of WordPress, and have good rankings and evaluations (at the least 4 stars).

There are a few suggestions right here. Yoast Duplicate Post and Duplicate Page or Post are each well-received and persistently maintained. However, let’s offer you an instance utilizing the Duplicate Page plugin, which is arguably the best resolution out there:

The Duplicate Page plugin.

Once it’s installed and activated, head to your Pages > All Pages display screen inside WordPress. From right here, hover over the page you’d prefer to duplicate, and search for a Duplicate This hyperlink:

The Duplicate This link.

Clicking this will clone the page in query – job completed!

4. Add Code to Your functions.php File to Duplicate Your Page in WordPress

Our last technique is arguably the hardest to implement, however provides the best flexibility and implementation. Adding code to your functions.php file is nice for a lot of duties, not least duplicating pages in WordPress.

You can add a hyperlink to your Pages dashboard display screen, which suggests it’ll all the time be there if you want it. However, earlier than you start, you’ll want some issues in place:

  • An acceptable textual content editor. Atom, Sublime Text, or Notepad++ are all free (or include trials), and even a default textual content editor will do in a pinch.
  • A File Transfer Protocol (FTP) shopper. FileZilla or CyberDuck are great choices and will offer you a good method to enter your site. Your hosting supplier may offer a File Manager, which does the identical factor.
  • Access to your site’s server. The credentials for this could often be discovered inside your hosting management panel, or by an email despatched to you if you first bought an account.
  • The expertise to manage your site by FTP. If this is one thing you have to brush up on, the Make WordPress website has a great FileZilla tutorial that may be tailored to different shoppers.
  • A baby theme is primarily based on your present father or mother theme. This helps protect your modifications when updates are made, and we’ve mentioned how to do that in the previous.

Once you’re prepared, open up your FTP shopper, and observe alongside!

Step 1. Open Your functions.php File

First, log into your site by your FTP shopper, and search for the wp-content > themes folder:

The wp-content > themes folder.

Inside, needs to be your youngster theme’s folder containing a functions.php file. It will not be there, in which case you’ll create it first. Next up, is enhancing it.

Step 2. Add Code to Your functions.php File

Once you have got your functions.php file open, you’ll need to add the next code. It ought to go despite everything of the opposite code that’s probably in there:

/* Duplicate posts and pages function. Duplicates seem as drafts, and the user is redirected to the Edit display screen. */

function rd_duplicate_post_as_draft(){
    international $wpdb;
    if (! ( isset( $_GET['post']) || isset( $_POST['post'])  || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
        wp_die('No publish to duplicate has been equipped!');
    }

/* Nonce verification */
if ( !isset( $_GET['duplicate_nonce'] ) || !wp_verify_nonce( $_GET['duplicate_nonce'], basename( __FILE__ ) ) )
    return;

/* This will get the unique publish or page ID */
$post_id = (isset($_GET['post']) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );

/* …then grabs the unique publish information. */
$publish = get_post( $post_id );
     
/* To choose one other user because the publish writer, use $new_post_author = $post->post_author;. Otherwise… */
$current_user = wp_get_current_user();
$new_post_author = $current_user->ID;
     
/* If the publish information exists, create the duplicate */
if (isset( $publish ) && $publish != null) {
    /* Create a new publish information 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 publish utilizing wp_insert_post() */
        $new_post_id = wp_insert_post( $args );
     
        /* Get all present publish phrases, then set them towards the brand new draft. */
        $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for publish sort, 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 of the publish metadata */
        $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");

        if (rely($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' ) proceed;
                $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->question($sql_query);
        }
     
        /* Redirect to the Edit publish display screen for the brand new draft */
        wp_redirect( admin_url( 'publish.php?motion=edit&publish=" . $new_post_id ) );
        exit;
} else {
        wp_die("Post creation failed, couldn't discover unique publish: ' . $post_id);
    }
}

    add_action( 'admin_action_rd_duplicate_post_as_draft', 'rd_duplicate_post_as_draft' );
     
    /* Add the duplicate hyperlink to the motion record for post_row_actions */
    function rd_duplicate_post_link( $actions, $publish ) {
        if (current_user_can('edit_posts')) {
            $actions['duplicate'] = 'ID, basename(__FILE__), "duplicate_nonce' ) . '" title="Duplicate this item" rel="permalink">Duplicate';
        }
        return $actions;
    }
     
    add_filter('post_row_actions', 'rd_duplicate_post_link', 10, 2 );

    add_filter('page_row_actions', 'rd_duplicate_post_link', 10, 2);

Once you’ve added the code, save your modifications and sign off of your FTP connection.

Step 3. Check You Can Duplicate a Page

Finally, refresh your're again-finish and head to your Pages display screen. You’ll see the duplication hyperlink seem as earlier than:

The Duplicate link in WordPress.

With the correct data, you possibly can simply flip this into a plugin and broaden the performance even additionally, though it really works nicely sat inside your youngster theme’s functions.php file.

How to Choose the Right Method to Duplicate Your Page in WordPress

When it involves duplicating your pages, the tendency to go for the quickest resolution is smart. However, in our opinion, you could need to contemplate an extra advanced possibility relying on your wants.

For most users who merely must duplicate a page in WordPress, a plugin is going to be your best wager. You can set up and activate it when vital, and it will provide the performance you want (and extra in some circumstances).

However, for those who’re a heavy ‘duplicator’, probably with advanced wants, hardcoding a resolution to duplicate your pages in WordPress makes excellent sense. It will all the time be there and will deliver a customized experience primarily based on your wants.

Of course, there’s additionally a budgetary concern in some conditions relying on these wants, however, for those who’re getting the performance you need, it’s cash price spending.

Wrapping Up

On the floor, a job reminiscent of duplicating a page in WordPress needs to be an easy button push. Depending on your experience and data, some approaches can appear rather more advanced.

In this publish, we’ve checked out 4 methods to duplicate a page in WordPress, with various levels of problem. Let’s rapidly recap them:

  1. Copy and previous your content manually, though be ready to sink time into the duty when you have a lot of pages.
  2. Alternatively, use built-in Block Editor performance – though an extra-strong resolution is higher.
  3. Take the basic strategy and use a plugin to duplicate your pages, reminiscent of Duplicate Page.
  4. Crack open a textual content editor and add code to your WordPress functions.php file.

Are you on the lookout for a method to duplicate a page in WordPress, and in that case, which of these choices appeals to you? Let us know in the comments part under!