How to import comments into Disqus using the generic WXR XML format
I recently moved over the entire Seopher.com commenting system to be powered by Disqus. However, because this blog is a custom build, I'm not running on a known blogging engine, so I couldn't do an easy export to then import my old comments into Disqus.
Fortunately Disqus allows you to import a generic WXR XML file, so it was just a case of generating this file and importing it. However I had a bit of trouble with the format, so thought I'd document the setup that actually worked for me.
What we're looking to do
I simply wished to take every single comment in my database and format it correctly into the WXR XML schema so that Disqus could import it and I'd then have my old ~3,000 comments on the same platform as the new ones.
However, the WXR schema had a few weird bits in it which caused import errors, so I've written this post to explain the schema I used (and any data formatting issues).
The Schema:
The below code box shows the full schema for a single comment on an article (selected at random, for demonstration purposes).
There are a few items I'd like to discuss specifically:
wp:comment_id
With this attribute, Disqus will determine whether the comment already exists or not. I originally did an import but messed up the date formatting (more on that shortly), deleted all the comments and found myself unable to re-import. Basically Disqus uses this field as the unique identifier for the comment. As a quick fix, I simply added 9 million to the value to ensure that the second import I attempted would detect them as unique.
wp:post_date_gmt and wp:comment_date_gmt
This needs to be done in this exact format (2007-09-06 00:49:12). For ease, here's the PHP date format that does this (where $value is whatever you've saved your post-date as, strtotime is pretty smart).
And that's pretty much it. I successfully managed to import a few thousand comments using this method and they all came through okay. Simply change the values in my schema (above) for whatever you have and you should be good to import.
If this was useful to you (or maybe even didn't work), let me know in the comments.
Enjoy this article? Why not subscribe to the full RSS feed?



