Merging WordPress posts from different databases

I have development and production versions of my website (on the same hosting). I want to easily synchronize the content between these versions. On the production website, content is updated daily.

I cannot use the XML export function because duplicate posts would be created on the development website.

Currently both websites uses different databases, but if there is a solution that allows for usage of only one database I gladly will go through it.

1 Answer
1

If you never send/sync Production posts to live.

Then just pull/copy the live database to the development database via mysqldump (or similar) and use wp-config vars to force the site and blog URL.

Use the following in the dev versions wp-config.php to force the URL’s

define('WP_HOME','http://example.com');
define('WP_SITEURL', 'http://example.com');

You may as well sync the entire database, rather than just posts, so then you get all the post revisions as well as any plugin configurations/data.

This is my normal method of developing a live site, locally. (Grab live DB drop Dev DB import Live DB into Dev) (The only fun bit is sending specific plugin configs up to the live site from the dev site)

Leave a Comment