Sync WordPress Staging to Live: Posts & Pages
In this article
Moving content from a WordPress staging site to your live site is a common task, but doing it manually page by page is slow and error-prone. This guide shows you how to sync posts and pages between staging and live environments safely, preserving your content, media, and settings. You'll learn both a plugin-based method and a manual database approach, plus how to avoid the classic mistakes that break a live site.
What You'll Need
- Access to your WordPress admin dashboard on both the staging and live sites.
- FTP or cPanel file manager access (for manual method).
- phpMyAdmin or a database management tool (for manual method).
- A backup of your live site (always recommended before any sync).
- A reliable migration plugin (e.g., UpdraftPlus, All-in-One WP Migration, or WPvivid) for the plugin method.
Step-by-Step
Method 1: Using a Migration Plugin (Recommended)
- Back up your live site. Before anything else, create a full backup of your live site (files and database). Most migration plugins offer this feature; alternatively, use your hosting control panel.
- Install a migration plugin on both sites. In both staging and live WordPress dashboards, go to Plugins > Add New, search for a migration plugin like UpdraftPlus or WPvivid, install and activate it on both.
- Export from staging. On the staging site, go to the plugin's settings (e.g., UpdraftPlus > Backup/Restore). Click Backup Now and include the database and all files. Wait for the backup to complete, then download the backup files to your computer.
- Import to live. On the live site, go to the same plugin's settings and choose Restore or Import. Upload the backup files you downloaded. The plugin will extract and restore the database and files.
- Update URLs. After import, the live site may have staging URLs. Use the plugin's URL replacement tool (or a search-replace tool like “Better Search Replace”) to change all instances of
staging.example.comtoexample.comin the database. Some plugins do this automatically. - Clear caches. Clear any caching plugins on the live site and your browser cache. Then verify all posts and pages look correct.
Method 2: Manual Database Sync (For Posts and Pages Only)
- Back up the live database. In phpMyAdmin (or your database tool), export the live site's database as a .sql file. Keep this safe.
- Export posts and pages from staging. In phpMyAdmin on the staging site, select the database, then click the Export tab. Choose Custom and select only the following tables (assuming the default
wp_prefix):wp_posts,wp_postmeta,wp_terms,wp_term_taxonomy,wp_term_relationships, and optionallywp_commentsandwp_commentmetaif you want comments. Export these as a .sql file. - Clean the staging export. Open the exported .sql file in a text editor. You must remove any
INSERTstatements for posts that already exist on live (like default pages). This is tricky; a simpler approach is to delete all rows from these tables on the live site first (see next step). - Clear the live tables. In phpMyAdmin on live, empty the tables you are importing into (e.g.,
wp_posts,wp_postmeta, etc.). Use the Empty operation. This deletes all existing posts/pages, so ensure your backup is solid. - Import the staging file. In phpMyAdmin on live, click the Import tab, choose the cleaned .sql file, and run it. This will insert all posts and pages from staging.
- Fix URLs in the database. Run a search-replace on the live database to change staging URLs to live URLs. You can use phpMyAdmin's Search > Replace feature, or a plugin like Better Search Replace. Be careful to replace only the domain, not the path.
- Regenerate permalinks. Go to Settings > Permalinks on live and click Save Changes to flush rewrite rules.
Common Mistakes
- Forgetting to update URLs. The #1 mistake. If you don't replace the staging URL, images and links break.
- Overwriting the entire live site. When using a full backup restore, you replace everything, not just posts/pages. This can lose recent comments, plugin settings, or new posts on live.
- Not backing up first. Skipping a backup can lead to irreversible data loss.
- Mixing table prefixes. If your staging site uses a different table prefix (e.g.,
wp_staging_), the manual import will fail. Always check prefixes. - Importing while live site is active. If you don't put the live site in maintenance mode during import, users may see errors or half-imported content.
Tips
- Use a staging-specific plugin. If your host provides staging (like WP Engine or Flywheel), use their built-in push-to-live feature—it's the safest and easiest.
- Test on a subdomain. Before syncing, test the import on a temporary subdomain to ensure everything works.
- Keep a log of changes. Note which posts/pages you've changed on staging so you can verify they appear correctly on live.
- Use a search-replace plugin. For URL replacement, use a dedicated plugin like “Better Search Replace” instead of manual SQL queries—it's safer.
- Sync media too. If you only sync posts, images may break. Use a plugin that handles media, or manually upload new images to live via Media > Add New.
Troubleshooting
- Images broken after sync. This is almost always a URL issue. Run a search-replace again, ensuring you replace the full staging URL (including
http://orhttps://) with the live URL. - Posts not appearing. Check that the posts are not in draft or trash. Also, ensure the
wp_poststable has the correctpost_status(should be 'publish' for live). - 404 errors on pages. Go to Settings > Permalinks and click Save Changes to flush rewrite rules.
- Database import fails. This is often due to file size limits. Use a plugin like UpdraftPlus or split the SQL file. Also check that you have the correct table prefix.
- Plugin conflicts after import. If the live site behaves oddly, deactivate all plugins and reactivate them one by one to find the culprit.
- Staging changes not showing. If you used a full backup restore, you may have overwritten live with an older staging version. Ensure your staging is up-to-date before exporting.
Frequently Asked Questions
Can I sync only certain posts, not all?
Yes. With a plugin like WPvivid, you can choose specific tables or use the “Export” feature to include only certain post types. For manual method, you'd need to filter the SQL export, which is more complex.
Will syncing overwrite my live site's comments?
If you include the comments tables in the sync, yes. If you only sync posts and pages (not comments), then existing comments on live will remain, but new comments on staging won't be transferred.
Do I need to sync media files separately?
Most migration plugins include media in the backup. If you're doing manual database sync, media files (images) are stored in wp-content/uploads, so you need to upload new images from staging to live via FTP or the media library.
Is it safe to sync from staging to live directly?
It's safe if you have a backup and follow the steps carefully. Always test on a staging copy of live first if possible.
What if my staging site is on a subdomain like staging.mysite.com?
That's fine. Just ensure you replace the entire domain in the database after import. Use a search-replace tool to change staging.mysite.com to mysite.com.
Can I schedule automatic syncs?
Some premium plugins (like WPvivid or ManageWP) offer scheduled syncs. Free methods require manual execution each time.