How to Copy an Elementor Page from One Site to Another

Recently, I’ve been doing a lot of work with Elementor, specifically, developing integrations with my plugins, mostly because I receive many requests from my customers. Personally, I prefer using the Block Editor on my projects, but Elementor is the most popular page builder after all. Since it is used on a huge number of WordPress websites, my goal is to make my plugins work flawlessly with it.

In this step-by-step guide, I’d like to show you two ways of copying a page created with Elementor to another site:

  1. Using a crossposting plugin (we will use the Simple WP Crossposting plugin),
  2. Programmatically (in this method, we will do it with the WordPress REST API).

There is also a third, partial way, which comes down to exporting and importing your Elementor templates. It doesn’t require any knowledge, and you can learn to do it either intuitively or just by watching a random video on YouTube.

Now, let’s jump straight into our two methods.

Copy an Elementor Page to Another Site Using a Plugin

Before we dive into the coding stuff and a detailed explanation of how things work under the hood, I’d like to remind you that you can easily copy pages created with Elementor from one site to another using my Simple WP Crossposting plugin.

Please, check the screenshot below to get an idea of how it is going to work:

how to copy an Elementor page from one site to another example
Here, I have the WordPress Classic Editor activated, and I recommend using it for pages created with Elementor. But using the new Block Editor will also work here.

Here are a few more details about how it is going to work:

The plugin works great with both a free version of Elementor and Elementor PRO.

Make sure your sites are using the same Elementor layout

It doesn’t matter which way you choose to copy an Elementor page to another site – in any case, you will need to make sure that all the sites are using the same Elementor layout.

It is a really big deal because if they don’t, your Elementor pages will be copied from one site to another, but they will be empty, without any widgets at all.

So, let’s go to Elementor > Editor > Settings > Features and make sure the “Container” option is either activated or deactivated across all the sites you’re about to copy a page between.

Container feature settings in Elementor
Make sure that you have the same option value of the Container feature (either Active or Inactive, but on all sites).

Copy an Elementor Page to Another Site Programmatically

Is using the plugin not an option for you? No worries at all. Let me show you a programmatic way of copying an Elementor page from one site to another.

It would probably be a little bit more complicated, but I am sure we can figure it out.

How Elementor stores its content

Before we dive into the coding itself, we need to get a clear picture of how Elementor structures its content (Elementor widgets and their settings) and how it is stored in the database.

For example, if you take a look at the post_content value in the database, we will notice that it is a mess. However, what I like about Elementor is that it does not use an excessive amount of WordPress shortcodes like other page builder plugins do.

To get a clear understanding of how it works, let’s take a quick look at the table below:

The Block EditorElementor
The blocks and their configuration are stored in post_content, in wp_posts table.Elementor widgets and their settings are stored in a single custom field _elementor_data which is obviously in the wp_postmeta table.

The data is stored in the _elementor_data field as a JSON string, it may look something like this:

An example how Elementor stores its content in _elementor_data
I used the json_decode() function to show you the value of the _elementor_data custom field in a structured way as an object.

The pages created with Elementor have some other custom fields, but _elementor_data is the main one; without it, nothing is going to work.

Registering custom fields (metadata)

So, when we want to copy an Elementor page from one site to another, the main thing we should worry about is copying the _elementor_data custom field.

Since we’re copying pages to another site with the WordPress REST API, we have to register custom fields, specifically the _elementor_data one on the other site. We can do it with the help of a register_meta() function that can be used inside the init hook.

If you’re using the latest version of Elementor, this step is now optional.

add_action( 'init', function() {

	register_meta(
		'post', 
		'_elementor_data',
		array(
			'type' => 'string',
			'show_in_rest' => true,
			'auth_callback' => '__return_true',
		)
	);

} );

A couple of things to remember here:

This was kind of a preparation step, and we’re done with it.

Copying an Elementor page from one site to another using a PHP function and the save_post hook

It seems like we’re done with the whole bunch of preparation steps, and we’re ready to copy our Elementor page to another site. As I already mentioned before, we’re going to use the WordPress REST API for that.

Below, you can find a custom PHP function that you can use on the original site. You need:

By the way, if you don’t know where to get an application password for the REST API request, please check the step-by-step explanation here.

/*
 * @snippet Allows you to copy an Elementor from one site to another
 * @author Misha Rudrastyh
 */
function rudr_copy_elementor_page_to_another_site( $page_id ) {

	$page = get_post( $page_id );	
	$elementor_data = get_post_meta( $page->ID, '_elementor_data', true );

	$page_data = array(
		'title' => $page->post_title,
		'status' => 'draft', // $page->post_status,
		'slug' => $page->post_name,
		'menu_order' => (int) $page->menu_order,
		// we still need to copy an Elementor page content
		'content' => $page->post_content,
		'meta' => array(
			// surely, the Elementor page most likely will have other meta data
			// but this is the only one required
			'_elementor_data' => $elementor_data,
		),
	);
	

	// we need this data to connect to REST API
	$login = '';
	$pwd = '';
	$url = '';
	
	$response = wp_remote_post(
		"{$url}/wp-json/wp/v2/pages",
		array(
			'headers' => array(
				'Authorization' => 'Basic ' . base64_encode( "$login:$pwd" ),
				'Content-Type' => 'application/json; charset=utf-8',
			),
			'body' => json_encode( $page_data )
		)
	);
	
	if( 'Created' === wp_remote_retrieve_response_message( $response ) ) { 
		// Everything is great!
		return true;	
	} else {
		return false;	
	}
	
}

What else would I like you to know about this code?

If you want the pages to be copied automatically, you can connect this function to the save_post action hook (or only for pages – save_post_page).

// if you want to copy Elementor pages to another site automatically
add_action( 'save_post', 'rudr_copy_elementor_page_to_another_site', 25 );

If this whole part seems complicated for you, you can always use my plugin instead. Please let me know your thoughts in the comments section below.

Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 15 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X