Migrating Comments in WordPress with Disqus

Migration is a pain. Don’t believe me? Ask any developer who’ve migrated an above average quantity of content from one WordPress install to another.

You lose pieces here and there (at times) and when the post type and taxonomies needs shuffling, it’s another ball game.

Recently I had a task to migrate content from a website which had around 3,000+ posts and 1,500+ comments. The whole data was residing under ‘post’ post type and had numerous taxonomies associated with it (more than 300). On the new version of the website, the content was divided in post types and meaningful distinctions of taxonomies.

The hurdle of arranging the data once again was done manually, where we provided the list of Title, URL and current taxonomy associations to the client and then the team on their end bifurcated the data to suite the new pattern. It was done, and was successful. I’d like to give a solid thumbs up to the team of WP All Export and WP All Import, as their tools provided an enormous ease in this migration process.

Now, the major scuffle was Comments. I prayed to all the new and old gods, wept and screamed in the darkness. It took me hours to find an obvious solution that we might be missing, which can just migrate the comments to the new URLs (as in new install we had new CPTs and taxonomies), but there was no such thing.

Suddenly a fix struck me and I started looking into it, and Voila!

You know Disqus? It’s a third party integration for WordPress, which allows you a better interface of comment management and moderation. Lesser know fact – it also offers tool if in case you are changing domains and URLs. There it struck me.

Migrating comments from Site A to Site B

  1. I created a disqus account and mapped it to the already running install of Site A.
  2. Then I ran the Sync, which synced all the existing comments to Disqus. So, basically, Disqus had a copy of all the comments that existed on Site A.
  3. I then logged into the Disqus account and used the URL Mapper option. This option provides you the method to change the URLs if your site changes it’s URL structure and you need to adjust the comment (linked posts’s) URLs. I generated the CSV of all the existing Post URLs where the comments existed.
  4. After this, we created another account of Disqus and mapped it to Site B.
  5. We then went to Site A and used default import tool of WordPress to take import of Post’s assets.
  6. The XML we got in Step 5 was then fed to disqus (which was mapped to Site B). So, now the Disqus account of Site B had comments which actually had post URL structure of Site A.
  7. We then wrote a script. (Will explain later).
  8. As the output of the script we wrote in Step 7 we got new post URLs where the comments were made.
  9. We imported the new CSV (of Step 8) to Disqus of Site B and in next 24 hours all the comments were mapped to the new URL structure.

Now the things to note:

Disqus had a Domain Migration Tool which can be used instead of all the above steps, if you are just doing like siteA.com/post-url TO siteB.com/post-url

But, in our case it was like siteA.com/post-url To siteA.com/cpt/post-url . So, basically the domain name had to be the same but between the domain name and the post-url slug, we had to insert the cpt titles. This cannot be done by the standard Domain Migration Tool.

So, the script that we wrote in Step 7 enabled us to identify the common part of the URL from new and old pattern and then replace the old url structure to the new one. My collegue Ronak wrote that one.

In case, if you are wondering that where did we get the new post url structure – We first imported all the 3000+ posts in the new install and then exported the URL csv by using WP ALL Export. Then we used that CSV and the CSV provided by Disqus (of old site’s comment post-url) and made one common CSV which was used by the script to do the old-to-new url replacement.

Also, be advised, that Disqus URL Mapper changes are not 100% successful and we too lost few comments in this transition, but losing something in place of everything sounds much better.

I know, all the aforementioned is quite difficult to grasp by reading in one go, so if you have any queries, comment and I’d try my best to respond and resolve your concerns. Also, please let me know if there exists a better approach (and if I’ve watsed all my hours :p).

2 thoughts on “Migrating Comments in WordPress with Disqus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s