DISQUS is a pretty good service which makes it easier for people to comment and track their contributions under a single profile across multiple sites. To use it with WordPress you install a plugin which is supposed to sync comments between itself and your local database. Whether it was a problem with the plugin or something I did I’m not sure but unfortunately something went wrong last night and I ended up with my local WordPress database containing duplicates of all my comments (not good).
Having first disabled the plugin I tried to restore my comments from the previous days backup but unfortunately due to a character encoding issue that didn’t work either and I was left in an even bigger mess! Using the import feature of the DISQUS plugin didn’t seem to do much good either as only about 1/5 of my comments were being synced back to WordPress and there didn’t seem to be a way to force it do the rest.
After contacting their very helpful support people I managed to find a rather unorthodox solution which I thought I’d share in case anyone else comes across the same problem. The following assumes that all your comments were successfully imported into DISQUS prior to any problems and that now you want to sync them back into WordPress (it’s also not for the technologically faint of heart!) –
- Disable the DISQUS plugin and backup your WordPress database (essential).
- Create a new empty wp_comments table in your WordPress database by running this SQL script (e.g. mysql -uusername -ppassword databasename < wp_comments_table.sql). This drops the old one before creating the new version. If you’re not familiar with MySQL commands there are plenty of reference guides available online.
- Re-activate the DISQUS plugin. If you click “Import” under the “Advanced Options” tab of the plugin you may see some/all of your comments re-sync but in my experience this didn’t work fully.
- You’ll notice that every time you visit a post that it syncs any comments back to the WordPress database. This is fine, but if you have hundreds or even thousands of posts it’s going to take a long time. You could wait for Google to re-index those pages but that usually takes weeks or months so the quicker way is to use a tool to crawl your site automatically. I used Xenu’s Link Sleuth (free) which is designed to find broken links but by running it over your site will also trigger the sync for each post.
- Depending on your host you will probably want to change the rate at which you crawl the site otherwise you may get timeout errors. I found that by setting Xenu’s Link Sleuth to 10 parallel threads was the optimum speed (you can find the setting under “More options”). You may also want to exclude certain directories such as /wp-content/ to reduce the crawl time.
- Sit back and wait for the crawl to complete. You’ll notice all your comments begin to appear back in your WordPress database, the number of which can be seen under the main dashboard 🙂
Your millage may vary with the above and I hold no responsibility for any adverse effects but hopefully it may be of help. Apparently the latest version of the plugin (2.02) fixes the duplication issue I experienced.