How to Copy a Page from One WordPress Site to Another
In this tutorial I would like to cover two ways how you can copy a WordPress page from one site to another. I am not going to use the export and import approach, because I think it is too complicated and requires extra steps which we normally don’t need.
And of course everything in this tutorial applies not only to regular WordPress pages, but also:
- pages with tons of custom fields (ACF, Carbon Fields, Simple Fields etc),
- pages, created with page builders (Elementor, WPBakery, Beaver Builder etc).
- pages, created with either classic or the block editor.
So let’s get started now.
Method 1. Using a Plugin
In the first method I describe how you can do it with my plugin, because it is the easiest, almost one-click method. Definitely easier than dealing with all the code from the second method.
All right, so, in order to copy pages from one WordPress site to another using this method, you just need to do three simple steps:
- Install my Simple WordPress Crossposting plugin.
- Add a website in plugin settings (and optionally configure the settings for your needs).
- Either go to the page edit and copy it from there:

or you can also copy it from “All Pages” admin screen:

You can learn more about and get my Simple WordPress Crossposting plugin here.
That’s all for the simple approach guys, only three simple steps as promised, and right now we’re going to dive deep into the code approach in case you’re uncomfortable with using third party plugins on your website.
Method 2. Without Plugins (with WordPress REST API)
It is also possible to copy pages from one WordPress site to another without plugins at all. But unless your pages are the part of the same multisite network, the only way to do it – with the WordPress REST API.
Below is a step-by-step example how to do it.
2.1 Decide about custom fields and register all of them on the second website
Most likely your page isn’t only the title and the content and has some custom fields. Even when you work with Elementor, it has all the data stored as a JSON string in literally one custom field which is _elementor_data
by the way.
The main point here is if you just provide all the custom fields into your REST API request, then nothing will happen and the page copy isn’t going to have the same custom fields as the original one, so we need to register every custom field on the second website with register_meta()
function.
Example:
register_meta(
'post',
'custom_field_key',
array(
'type' => 'string',
'show_in_rest' => true,
)
);
You need to do it for every custom field, more examples you can find in this tutorial.
2.2 Create a PHP function to copy WordPress page from one site to another
Below is the complete function but the question is – where should we run it in our website code? And there are actually different options:
- First of all you can, of course, copy the pages to another website automatically every time you hit the “Publish” button. Action hook
save_post_page
will help you with that. - You can create a bulk action and connect this function to it.
- Another option is like on the screenshot above, you can display the checkboxes in the block editor sidebar and only copy a page to another website when an appropriate checkbox is checked.
And here is the function code:
/*
* Allows to copy WordPress page to another site
* @author Misha Rudrastyh
*/
function rudr_copy_wordpress_page_to_other_site( $page_id ) {
// we need this data to connect to REST API
$login = '';
$pwd = '';
// let's get page data
$page = get_post( $page_id );
// the array with the page data for the REST API request
$page_data = array(
'title' => $page->post_title,
'status' => $page->post_status,
'date' => $page->post_date,
'slug' => $page->post_name,
'menu_order' => $page->menu_order,
'content' => $page->post_content,
// 'parent' => $page->post_parent,
'meta' => array(),
);
// it is time to add meta fields into the request
$page_meta = get_post_meta( $page_id );
foreach( $post_meta as $meta_key => $meta_values ) {
// don't forget that there are could be multiple meta values for the same key
// we're just using a simplified version here
$meta_value = reset( $meta_values );
// sometimes we need to do extra stuff here like maybe_unserialize()
// if you don't want to worry about it, check my plugin ;)
// add to the REST API request body
$page_data[ 'meta' ][ $meta_key ] = $meta_value;
}
$response = wp_remote_post(
'https://ANOTHER-WEBSITE/wp-json/wp/v2/pages',
array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( "$login:$pwd" )
),
'body' => $page_data
)
);
if( 'Created' === wp_remote_retrieve_response_message( $response ) ) {
// Everything is great!
return true;
} else {
return false;
}
}
Some comments to this code:
- First things first, if you don’t know where to get
$login
and$pwd
values, read about application passwords. - Also you can see that I’ve commented
parent
parameter, why? Because the parent page ID on Site 1 and on Site 2 is going to be different. Most likely we will need to send one more REST API request to get a parent page ID by slug.

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 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