How to Copy a Page in WordPress & Elementor

How to Copy a Page in WordPress Elementor

Pages are an essential part of a website. WordPress page is defined as a post-type that contains static content. These pages hold the information of websites that are least likely to change. 

The content of the pages doesn’t need to be altered too much as it holds constant information. And when you have a big website, some pages will contain the same design with content varying here and there. In that case, creating pages after pages is very painful. 

What if we told you that you could duplicate pages in WordPress? Yes, today, we will show you how to copy a page in WordPress Elementor, a world-class page builder plugin. It currently has more than 5 Million+ active installations. It has widgets and features that will let you create any professional website with ease. 

Let’s use Elementor to duplicate pages on your website. 

But first, check how to copy a page manually.

How To Duplicate a WordPress Page Manually 

This process is for those people who believe in do it yourself approach. You can copy a WordPress page using custom code. This method will save you some time by adding another plugin to your WordPress site and affecting the performance. 

However, if not installing another plugin is essential to you, this approach is acceptable and will work with the regular editor content and Elementor.

There is a catch. To use this code, you need to add it to either the functions.php file of your theme or a code management plugin like Code Snippets. If you add it to the functions.php file, use a child theme.

$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'] = '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 );

However, before using this code, you need to know that the snippet will enable duplication for both posts and pages. If you are looking to only allow it for one or the other, you can remove the page_row_actions or post_row_actions filter at the bottom of the code snippet.

Read: How To Change Font Size in Elementor: Edit Your Typography Promptly

Block Editor (Gutenberg)

If you don’t want to go through the hassle of using custom codes, you can also use the Gutenberg editor. It will also save you a lot of time.

You can quickly duplicate the content from the block editor. First, open the editor for the post or page you want to copy.

Click the three-dot icon in the top-right corner to expand the menu. Then, choose the option to Copy all content:

duplicate content Gutenberg- how to copy a page in WordPress Elementor

Now, create a new post or page. Next, click into the editor and paste the content. You can do two things like:

  • Use a keyboard shortcut like Ctrl + V or Cmd + V.
  • Right-click and choose paste.

Lastly, you will see an exact copy of the original content in the editor. But, you have to make sure to add the title, categories, tags, etc., manually.

Feeling like this is too simple? Well, with Elementor, you can easily customize the duplicated page. 

Read More: Adding Product Filter in WooCoomerce

How to Copy a Page in WordPress Elementor

You need to follow the below steps to copy a page in Elementor. 

Step 1: Hit the Update Button and Then Save as Template

When building a page and when it is time to save it, click on the arrow next to the “UPDATE” button to open the Save Options. When those options open up, click on “Save as Template.”

Click on Update and select Save as Template to duplicate pages in Elementor

Step 2: Give a Name to Your Page Template

Now you will see a popup that will ask you to name the new page template that you want to duplicate. So, go ahead and give your page template a name and then click on the Save button.

Give your elementor page template a name and save it

Step 3: Access the My Templates Area

Next, the popup box will remain so you can simply click on the “My Templates” tab on the top right.

Click on my templates in elementor

You need to click the  “Import” button next to the saved page template you wish to use, and you are all set. 

In this way, you can repeat the process repeatedly and create as many duplicate templates as you want in Elementor.

Ready to Create Duplicate Pages in WordPress?

So, now you know how to copy a page in WordPress Elementor. You don’t need to spend time creating pages that have the same design output content. You can use the above methods to duplicate any page. 

That will save you a lot of time, and you can use that time to focus on the other aspects of your website.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top