3 Ways to Duplicate a Page or Post in WordPress

Reading time: 9 min read
Syed Balkhi
Written by
Syed Balkhi

Updated · Nov 22, 2023

Syed Balkhi
Entrepreneur. Investor. | Joined August 2023 | LinkedIn
Syed Balkhi

Syed Balkhi is the founder of WPBeginner, the largest free WordPress resource site. With over 10 yea... | See full bio

Florence Desiata
Edited by
Florence Desiata

Editor

Florence Desiata
Joined June 2023 | LinkedIn
Florence Desiata

Florence is a dedicated wordsmith on a mission to make technology-related topics easy-to-understand.... | See full bio

Techjury is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more.

Welcome to our comprehensive guide on duplicating a page or post in WordPress.

You might be wondering why one would need to duplicate a page or post in WordPress, and that’s a smart question. Doing so has many benefits instead of copying and pasting your old content. For instance, duplicating a page or post means duplicating your featured images, metadata, and other settings. Something that copying and pasting your writing won't do.

It's also a great way to make design changes while keeping the original page or post intact. Duplicating your pages or posts allows for testing variations of a page or post to see which one performs better or to build reusable templates for future use.

If you're interested in learning how to replicate your WordPress content easily and effectively, you've come to the right place. Let's dive into three ways to duplicate a WordPress post or page.

Duplicate Pages and Posts With SeedProd

The easiest way to duplicate your pages and posts while maintaining all settings is to use a plugin - SeedProd.

It is the best drag-and-drop page builder in the WordPress market because it has awesome additional features that most builders don't. It includes duplication or the cloning of your content.

So, make sure you install and activate SeedProd on your website. Once it's up and running on your site, you can begin duplicating your choice of posts and pages.

To Clone an Existing Landing Page

Go to SeedProd in your left-hand WordPress panel, click on and scroll down to your landing page list. Select the page you wish to clone, hover over it, and click the Duplicate link. The cloned page will appear at the top of your list as a new draft.

To Duplicate Blocks & Sections

SeedProd employs blocks, rows, and sections in its drag-and-drop page builder to assist in structuring your layouts. To clone a block in SeedProd, hover over it until an orange outline appears, then click the Duplicate Block icon.

An identical copy of the block will appear below the original.

To Clone Rows

Similarly, you can clone Rows by hovering over one until a blue outline appears and then clicking the Duplicate This Row Icon.

You can also clone entire page sections by waiting for the purple outline to appear and then clicking the Duplicate Section icon.

Use Yoast Duplicate Post Plugin

Here's a step-by-step guide on duplicating posts and pages using the Yoast Duplicate Post. As before, download the plugin to your WordPress dashboard, i.e., install and activate it.

Navigate to your Posts or Pages dashboard, depending on what you want to duplicate. You will find three new links under each post title: Clone, New Draft, and Rewrite and Republish. 

Choose the best option to duplicate a post:

  • Clone: Clicking the "Clone" link will produce a copy of the post without opening it in the post editor.
  • New Draft: The "New Draft" link will create a copy of the post and open it in the WordPress post editor, allowing you to edit it immediately.
  • Rewrite & Republish: Clicking on the "Rewrite & Republish" link will make a copy that opens in the WordPress editor. After editing the copied version, you can integrate the duplicated post back into the original post with the new changes. You maintain the same URL, featured image, and other details!

Check out the features of Yoast Duplicate Post above. Source

Clone multiple Posts or Pages by selecting several of them and choosing the Clone option from the Bulk Actions drop-down menu.

Add Your Code to Functions.php Using WPCode

Don't want to use a plugin but want to add code instead? Then, this means you'll have to add code to your functions.php file manually.

Adding your to your functions.php file manually is only a good idea if you are a skilled developer who knows what they're doing. Even if you're a professional programmer, you're better off using a code snippet tool to add your code.

I recommend using WPCode to add functionalities to your core functions.php file without risking your site's stability. 

First, install and activate the WPCode plugin.

Navigate Code Snippets in your WordPress admin bar dashboard. Click on the Add New button.

You can use a code from the pre-made library or add code from scratch. 

Click on Add Your Custom Code (New Snippet) and the ‘Use Snippet’ button.

Give your code a name and choose PHP Snippet in the Code Type drop-down menu on the right. 

Enter the following code in the Code Preview box:

// Add the duplicate link to action list for post_row_actions

// for "post" and custom post types

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

// for "page" post type

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

function rd_duplicate_post_link( $actions, $post ) {

if( ! current_user_can( 'edit_posts' ) ) {

return $actions;

}

$url = wp_nonce_url(

add_query_arg(

array(

'action' => 'rd_duplicate_post_as_draft',

'post' => $post->ID,

),

'admin.php'

),

basename(__FILE__),

'duplicate_nonce'

);

$actions[ 'duplicate' ] = '<a href="' . $url . '" title="Duplicate this item" rel="permalink">Duplicate</a>';

return $actions;

}

/*

* Function creates post duplicate as a draft and redirects then to the edit post screen

*/

add_action( 'admin_action_rd_duplicate_post_as_draft', 'rd_duplicate_post_as_draft' );

function rd_duplicate_post_as_draft(){

// check if post ID has been provided and action

if ( empty( $_GET[ 'post' ] ) ) {

wp_die( 'No post to duplicate has been provided!' );

}

// Nonce verification

if ( ! isset( $_GET[ 'duplicate_nonce' ] ) || ! wp_verify_nonce( $_GET[ 'duplicate_nonce' ], basename( __FILE__ ) ) ) {

return;

}

// Get the original post id

$post_id = absint( $_GET[ '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-&gt;post_author;

*/

$current_user = wp_get_current_user();

$new_post_author = $current_user-&gt;ID;

// if post data exists (I am sure it is, but just in a case), create the post duplicate

if ( $post ) {

// new post data array

$args = array(

'comment_status' =&gt; $post-&gt;comment_status,

'ping_status'    =&gt; $post-&gt;ping_status,

'post_author'    =&gt; $new_post_author,

'post_content'   =&gt; $post-&gt;post_content,

'post_excerpt'   =&gt; $post-&gt;post_excerpt,

'post_name'      =&gt; $post-&gt;post_name,

'post_parent'    =&gt; $post-&gt;post_parent,

'post_password'  =&gt; $post-&gt;post_password,

'post_status'    =&gt; 'draft',

'post_title'     =&gt; $post-&gt;post_title,

'post_type'      =&gt; $post-&gt;post_type,

'to_ping'        =&gt; $post-&gt;to_ping,

'menu_order'     =&gt; $post-&gt;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( get_post_type( $post ) ); // returns array of taxonomy names for post type, ex array("category", "post_tag");

if( $taxonomies ) {

foreach ( $taxonomies as $taxonomy ) {

$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' =&gt; 'slugs' ) );

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

}

}

// duplicate all post meta

$post_meta = get_post_meta( $post_id );

if( $post_meta ) {

foreach ( $post_meta as $meta_key =&gt; $meta_values ) {

if( '_wp_old_slug' == $meta_key ) { // do nothing for this meta key

continue;

}

foreach ( $meta_values as $meta_value ) {

add_post_meta( $new_post_id, $meta_key, $meta_value );

}

}

}

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

// wp_safe_redirect(

// add_query_arg(

// array(

// 'action' =&gt; 'edit',

// 'post' =&gt; $new_post_id

// ),

// admin_url( 'post.php' )

// )

// );

// exit;

// or we can redirect to all posts with a message

wp_safe_redirect(

add_query_arg(

array(

'post_type' =&gt; ( 'post' !== get_post_type( $post ) ? get_post_type( $post ) : false ),

'saved' =&gt; 'post_duplication_created' // just a custom slug here

),

admin_url( 'edit.php' )

)

);

exit;

} else {

wp_die( 'Post creation failed, could not find original post.' );

}

}

/*

* In case we decided to add admin notices

*/

add_action( 'admin_notices', 'rudr_duplication_admin_notice' );

function rudr_duplication_admin_notice() {

// Get the current screen

$screen = get_current_screen();

if ( 'edit' !== $screen-&gt;base ) {

return;

}

   //Checks if settings updated

   if ( isset( $_GET[ 'saved' ] ) &amp;&amp; 'post_duplication_created' == $_GET[ 'saved' ] ) {

echo '<div class="notice notice-success is-dismissible"><p>Post copy created.</p></div>';

   }

}

Below the Code box, you'll see options for insertion: Auto Insert and Shortcode.

Choose Auto Insert to launch the code and execute it on your site. Shortcode will allow you to add the code only to relevant places, but that's not relevant in this case.

Once you run your code, you're good to go. Now, you'll get the option to Clone or Duplicate your posts and pages from the respective areas.

Precautions:

Be aware that editing your `functions.php` file directly can break your site if not done correctly. Always use a code snippet tool like WPCode instead of editing your functions.php file directly.

Be wary when you make theme updates. Any changes to your original theme file will affect your edits in the functions.php file. Always create a child theme and activate it as your primary theme on your site. Any changes to your core files after that will remain unaffected by general theme updates. 

Be cautious with the duplication process, especially if you have many posts, as it may impact website performance.

Conclusion

Duplicating a page or post in WordPress can save you time and keep your site consistent.

It's easy to copy your pages' structure, theme, and content, helping maintain uniformity. You can achieve this by using plugins or inserting code into the function.php file. Remember that it's important to do it correctly to avoid negatively impacting your site's performance.

Choose the method that best suits your comfort level and site needs. A well-done duplication process can boost your site's effectiveness and online presence. So, get started and duplicate content on your site!

FAQs .


What is a duplicate post in WordPress?

Duplicate post in WordPress is creating an exact copy of a page or post. This helps maintain uniformity in the look and feel across multiple pages or posts on any website. Unlike copying and pasting content, duplicated posts and pages include metadata, featured images, and other details. 

How do I create duplicates in WordPress? 

The best way to create duplicate pages, posts, or even entire websites is to use the right plugin. Plugins like Duplicator are great for duplicating whole sites, while SeedProd and Yoast Duplicate Post plugins are great for only posts and pages. 

SHARE:

Facebook LinkedIn Twitter
Leave your comment

Your email address will not be published.