Importing Haloscan comments into WordPress (v2.3 and up) from Blogger

Note: Even though I originally wrote this for WordPress v2.3, it continues to work for all versions of WordPress through v2.9.x.


WordPress logoWho knew that when I migrated my Blogger blog to WordPress way back when, I’d still be supporting a hacked together Haloscan importer 3 years later!

Awhile back, I don’t remember if it was during WordPress 2.2 or 2.3, the folks at Google revamped Blogger, which meant the old Blogger importer no longer worked. So the heroic coders that do the heavy lifting for WordPress set out to write the-Blogger-importer-to-end-all-Blogger-importers, this time using Blogger’s feed-based “API”.

The problem for you classic Blogger folk with Haloscan comments is that the only way to link your Haloscan comments to their post is via Blogger’s postID. Which is apparently not accessible in the feed API. Grrr. Which meant my previous hack for associating the postID with the newly imported WordPress post no longer worked.

Last night, I finally went back to the drawing board and came up with a new solution. I’ve tested it successfully on two different blogs.

Step 1: Import your Blogger blog

Nothing to see here. Just follow the instructions in WordPress under Manage > Import.

Note: Apparently the Blogger importer built into WordPress doesn’t play well with self-hosted (aka FTP-published, R.I.P.) Blogger blogs. If you run into trouble running the Blogger importer, try first converting your Blogger blog to Blogspot-hosted with a throwaway subdomain, solely for the sake of doing the import.

Step 2: Run Get Blogger postIDs

I wrote a new utility plugin called Get Blogger postIDs that loops through every Blogger-imported post, fetches the old Blogger post, and grabs the postID. In order for this to work, the old Blogger blog must still be web-accessible.

In order for the plugin to find the all-important postID, your Blogger template needs to have Quick Edit links. If it’s a newer, stock template it probably does. If it’s an older or custom template, you may have to add <$BlogItemControl$> to your Blogger template and republish. View source on a published permalink page and search for postID= to find out.

Then follow these instructions:

  1. Download and unzip (v2.0)
  2. Upload wp-get-blogger-post-ids.php to /path/to/wordpress/wp-content/plugins/
  3. Activate the plugin (don’t forget!)
  4. Goto Manage > Get Blogger postIDs
  5. Enter the domain name of your blog (without the http:// or trailing slash). This is going to look like: or
  6. If you have a domain, you can skip the second text box. If you self-host your blogger blog, use the second text box to enter the URL path after the domain, but before the /yyyy/mm/permalink.html, but only if one exists. Common paths include weblog, blogger, and blog. Leave the path blank if there is none.
  7. Click the “Import Blogger postIDs” button

The plugin will print out every post permalink and the Blogger postID it finds. It may take some time to run, depending on the speed of your internet connection and the number of imported posts. Be patient. If something goes wrong, or if you don’t get the domain and path right the first time, don’t worry, you can safely rerun this plugin. It will print “Done!” at the bottom when it’s complete. As always, if you have any problems, leave a comment here.

Thanks to Mike Conover for v2.0 of wp-get-blogger-post-ids.php. It has better feedback messages and a mechanism to specify importing the ids for X posts at a time (useful if your webhost doesn’t like long running php scripts).

Step 3: Run the new import-haloscan.php script

The same prerequisite applies: only “premium” customers have access to Haloscan’s export comments feature. Bah! The only way to get around this limitation and access your comments for export is by donating $12 to Haloscan.

  1. Download and unzip (v3.1)
  2. Upload import-haloscan.php to /path/to/wordpress/wp-admin/
  3. log in to Haloscan
  4. go to Manage Comments > Export
  5. If you made your $12 donation, there will be an export link for every thousand comments you have. Clicking one of the export links will prompt you to save the file as “export.xml”. If there is more than one link (i.e. if you have more than 1000 comments), rename the first file to export1.xml, the second file to export2.xml, and so on. Save the files to your desktop and upload them to /path/to/wordpress/
  6. In your web browser, go to replacing with the domain name and path to your WordPress install
  7. Click OK at the bottom of the page to import your Haloscan comments

If anything goes wrong, my WordPress Suicide plugin is very handy for deleting all the imported comments and starting over again, without having to reinstall WordPress. Good luck!

Appendix: Importing Haloscan Comments into WordPress from a WordPress Blog

Once in a blue moon, someone leaves a comment and says they actually embedded Haloscan comments into their WordPress blog—usually because they were using Haloscan with a Blogger blog back in the day, and decided to leave the comments in Haloscan. If you find yourself in that boat, fear not. Just make the following modification to import-haloscan.php using a text editor (e.g. Notepad in Windows, TextEdit in Mac OS X, gedit in Linux) and follow the instructions in Step 3.

Replace lines 77-81:

$meta_records = $wpdb->get_results("select * from $wpdb->postmeta where meta_key = 'blogger_id'");

foreach ($meta_records as $meta_record) {
  $blogger_to_wordpress[$meta_record->meta_value] = $meta_record->post_id;

With the following:

$meta_records = $wpdb->get_results("select * from $wpdb->posts");

foreach ($meta_records as $meta_record) {
  $blogger_to_wordpress[$meta_record->ID] = $meta_record->ID;

Feel free to if you found this useful.