Syncing Posts or Pages From the Production Site to the Staging Site

Question: How can I sync posts or pages from my live site to my staging site (blog/dev)? There have been a lot of new posts while the staging site has been in development, and I don’t want to risk pushing my updates unless the posts are replicated across both environments.

Answer: Exporting the posts or pages is the first step of the process and can be done with tools directly on WordPress. Be sure to perform the export from the production site to copy the posts or pages to the staging site.

Export Posts and Pages From WordPress

1. Log in to the production site wp-admin.
2. Navigate to Tools > Export
3. Choose posts or pages for export:

Warning: Choose posts or pages only! Selecting all content would overwrite all posts, pages, and media. This may result in losing the changes made on the staging site.
4. Click on Download Export File.

Export posts and pages

Import Posts or Pages to WordPress

Importing posts or Pages into the staging site requires first exporting the content from the production site. Ensure you’ve downloaded the *.XML file from the previous step. Make sure to perform the import process on the staging site.

1. Log in to the wp-admin dashboard of the staging site
2. Navigate over Tools > Import. If you do not have the WordPress importer installed, you will see a prompt to install the plugin and must do so before continuing
3. Scroll down to WordPress and click Install Now
4. Now click on the Run Importer

5. Click on choose file and select the *.XML file

6. Click on the Upload file and import button.
7. Assign posts to existing WordPress users, and check the Download and import file attachments.

9. Finally, click on the Submit button.
10. All done, the new posts are imported, and existing posts are not touched.

Alternative Option: Update Posts and Pages with WP STAGING

Warning: This option is not recommended because WordPress stores all kinds of data in the mentioned tables below. So following this guide can lead to a loss of your changes and should only be done if you know what to do.

To do so, click on the WP STAGING update button and select the tables wpstg_posts and wpstg_postmeta only.

Exclude and unselect all other tables and folders except those containing your new images, if there are any!

Attention: Updating means that ALL posts and pages on the staging site will be overwritten with data from the live site!

These tables will be copied over to the staging site. If there are posts on the staging site that you do not have on the production site, you should create them on the live site to prevent these tables from being overwritten.

My advice for the future is to create content either on the staging site or to update the staging site more often. Then you ensure that both sites are not running much out of sync.

There is an article about the WordPress database structure that helps you to understand which database table contains data and makes your decision easier on which table needs to be excluded when you copy over data from one site to another: https://wp-staging.com/docs/the-wordpress-database-structure/

Updated on August 17, 2023