Importing Haloscan comments into WordPress from Blogger
Update, please read this first!
The instructions below only worked for WordPress 1.5, 2.0, 2.1, and 2.2 before Google released a new version of Blogger—which broke the WordPress importer. Since that time, these instructions have ceased to be useful. However, if you’ve recently imported your Blogger blog into WordPress 2.3 (or are planning to) and need to import your Haloscan comments, check out my new post created specifically for you: Importing Haloscan comments into WordPress 2.3 from Blogger. I’m leaving this post here for posterity, but since it’s no longer doing anybody any good, I’ve closed the comments.
Background
Judging by the response to my original moving from blogger to wordpress post, this is a popular topic. However, I only meant for that post to be useful to the next hacker down the line and not so much for the faint of heart. This post seeks to remedy that oversight with an improved script for importing Haloscan comments into WordPress.
This was made possible after Haloscan fixed their comment export feature so that html is no longer stripped from the comment text. The other night I looked back at some code I had pieced together based on Phil Ringnalda’s code from his post, Importing YACCS comments in Movable Type, and I was able to finish the Haloscan importer the way I had originally intended: without screen scraping! If you have any problems or suggestions, feel free to leave a comment. Enjoy.
Step 1: Upgrade Haloscan
Only “premium” customers have access to Haloscan’s export comments feature. Bah! The only way to get around this limitation and get access to your comments for export is by donating $12 to Haloscan. If you do make the donation, the instructions and code below (for versions 1.5.x and 2.x of WordPress) should work for you.
Step 2: Import Blogger posts into WordPress 2.x
If you’ve already imported your Blogger posts using WordPress 2’s importer without the modification below, you will need to delete the posts you’ve imported, make the modification described in step 2, and rerun the importer. Luckily I’ve created a plugin to make deleting all of your blog posts a snap.
- Open /path/to/wordpress/wp-admin/import/blogger.php in a text editor
- Find the following line (line 404 in v2.0.2)
$post_content = $postinfo[2];
and change it to this:
$post_content = "<!--" . $postinfo[3] . "-->" . $postinfo[2];
Explanation: This stores each blogger post id as an html comment at the beginning of the post, which is used later to associate the post with the appropriate Haloscan comments.
- Save the file and then return to a web broswer
- Log in to the WordPress administrative interface and select the “Import” option from the top menu, and then select “Blogger” and follow the instuctions for importing your posts
- Continue with Step 3: Importing your Haloscan comments below
Update: If you’re interested in maintaining the permalinks to your posts, I’ve written a post called Maintain permalinks moving from Blogger to WordPress that requires three additional changes to the blogger.php script, which need to be made before you run the import. (17-Oct-2006)
Step 2B: Import Blogger posts into WordPress 1.5.x
Note: This step is left here for historical purposes. WordPress 2 comes with a significantly more advanced importer for Blogger which should be used instead of the instructions below. If you’re importing into WordPress 2.x, skip to Step 3.
The instructions marked with an asterisk (*) below are slightly different from the instructions that come with the import-blogger.php script provided by WordPress. In particular, step 7 is crucial in order to import comments from Haloscan.
If you’ve already imported your Blogger posts into WordPress using the provided import-blogger.php script and you can’t or don’t want to delete the posts that you’ve already imported, I’ve written a script to insert the Blogger post IDs into your WordPress posts so that you’ll be able to successfully import your Haloscan comments.
Just download insert-blogger-post-ids.zip, unzip it, and upload insert-blogger-post-ids.php to your wp-admin directory. Then run it in your browser like you did import-blogger.php. Now you can skip down to the section entitled “Importing your Haloscan comments”.
- log in to Blogger
- go to Settings > Publishing and set FTP Path to your WordPress install e. g.
/path/to/wordpress/
- *change Blog Filename to
wordpress.html
explanation: prevents creating an index.html file in wordpress directory—this file can be deleted later - go to Settings > Formatting and change Timestamp Format to mm/dd/yyy hh:mm:ss tt (the first option) and set Enable float alignment to “No”
explanation: the second change prevents Blogger from inserting unnecessary formatting markup at the beginning and end of each post - go to Settings > Archiving and set Archive Frequency to “Monthly”, set Archive File name to
wordpress.php
, and set Archive Path to your WordPress install e. g./path/to/wordpress/
(should be the same as above) - *set Enable Post Pages to “No”
explanation: prevents creating post pages filed under directories named 2004, 2005, etc in your WordPress directory which would eventually collide with permalink rewrites - *go to Template > Edit Current and replace your template with the following line of code
<Blogger><wordpresspost><$BlogItemDateTime$>|||<$BlogItemAuthorNickname$>|||<!--<$BlogItemNumber$>--><$BlogItemBody$>|||<$BlogItemNumber$>|||<$BlogItemSubject$></Blogger>
explanation: includes the unique blogger post id within an HTML comment in the body of each post
- Click “Save Template Changes” and then click “Republish” to republish your blog
- goto http://example.com/wordpress/wp-admin/import-blogger.php where
example.com/wordpress
is replaced with the domain name and path to your WordPress install - click OK at the bottom of the page to import your Blogger posts
Step 3: Importing your Haloscan comments
import-haloscan.php has be revised for WordPress 2.x so that comment counts are now automatically incremented.
- Download and unzip import-haloscan-2.0.zip (v2.0)
- Upload import-haloscan.php to your wp-admin directory
/path/to/wordpress/wp-admin/
- log in to Haloscan
- go to Manage Comments > Export
Note: only “premium members” have access to export their comments, but if you’re really serious about leaving Haloscan, you might be willing to donate the $12 necessary to gain access to your comments for exporting. - 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 your WordPress directory
/path/to/wordpress/
- Go to http://example.com/wordpress/wp-admin/import-haloscan.php where
example.com/wordpress
is replaced with the domain name and path to your WordPress install - Click OK at the bottom of the page to import your Haloscan comments
Cool! I will definitely be sending people here for instructions!
well, i think this only works for Haloscan users with upgraded accounts
castell, thanks for the heads up. how disappointing!
i’ve just added notes to the post above describing that you’ll need to donate $12 to haloscan in order to export your comments cleanly.
:S too bad about the donating thing to get my comments :(
Justin, I’ve got someone having trouble adding a comments option to links in their linklog, because apparently wordpress doesn’t have this option. I see you have comments on your neatlinks, can you email me a howto?
katie, my neatlinks sidebar is a blogger blog that’s dynamically included in my wordpress blog template. the neatlinks comments are provided by haloscan.
recreating that scenario would take some doing as it requires a custom blogger template formatted to be included in another webpage, and some wordpress template know how.
that said i’d be happy to write up how i do it if you think it’d be useful.
ps. is this easyjetsetter katie?
Yep, hey mate. Hmm, ok I will pass it on that it is possible and see what is said in reply to that.
Hmmm… I tried it as described (or so I believe). I was able to get the haloscan comments in “export.xml” and uploaded it successfully to my wordpress directory (same level as all the archives, etc. and NOT in the admin area) and clicked OK, but it says “0 comments imported” I know that 222 comments exist, and that the export.xml file contains a lot of data (from Haloscan’s output).
What might I be overlooking?
david, were you previously using haloscan with wordpress or with blogger (or another blogging platform)?
if with blogger, when you imported your posts into wordpress from blogger, did you use the template above so that the blogger post ids were included in your wordpress post content?
blogger.com, originally
I believe I did. I copied it from your post.
However, having just moments before used the import-blogger.php, I went to the directory and deleted only the archive files beginning with dates… I did not delete the “wordpress.php” file someone else’s instruction said to create (in the blogger.com settings. I now have “wordpress.html” and “wordpress.php” in my wp directory, so I am getting a little confused…
if you’ve already run and successfully imported your blogger blog using the original blogger template on blogger-import.php, you will need to delete the records in the wordpress posts table (usually named wp_posts) before trying again using the modified template. you can do this using the mysql client with the following sql statement:
delete from wp_posts;
when doing this exercise EXTREME caution. that command will delete all records in the wp_posts table without asking you to confirm deletion. this will also delete any posts that you’ve written using wordpress since importing your posts from blogger. make sure to back these posts up manually if this applies to you.
if you don’t have access to the mysql client or are unfamilar with using it, you can use a web interface like phpmyadmin, often provided by your web host, to delete all the records in the wp_posts table. update: in order to do so, go to the phpmyadmin interface for the database that stores your wordpress posts, using your web browser. your webhost may have created this for you, in which case you may need to ask them how to get there. when you get there, you should see a list of tables on the left, which in all likelihood will begin with the prefix
wp_
. select wp_posts on the left, and if you select the browse tab at the top, you should see a listing of your posts. to empty the table, select the “Empty” tab at the top right and click OK when it asks if you’re really sure you want to do this. repeat the procedure for the wp_post2cat table.then delete the files generated by blogger to import into wordpress, update your blogger template with the template above, and republish your entire blog.
then re-run import-blogger.php followed by import-haloscan.php.
Hey, there! Just found your great tutorial. I’m going from iBlog (creates flat HTML files client side) to WordPress. I’m using Agitpropto export the content from iBlog into a Moveable Type formatted text file. There’s a WP import script to handle that.
Only thing that Agitprop doesn’t do is export the blog ID. I can do this myself with the custom tags that iBlog supports, but I’m not sure where your script is expecting the ID to reside. Body? Abstract? Top or bottom? Anywhere?
Rob, import-haloscan.php is expecting the post_id to live inside an html comment at the very beginning of the post body. in fact it grabs the post body, strips it of any leading/trailing whitespace, and then looks for
<!--
at the very beginning. if it doesn’t find it, it moves onto the next post, if it does, it looks for the following-->
and grabs the substring in between.definitely let me know how it goes, it will be interesting to see how it works under different (non-blogger) circumstances.
Hey, Justin, I tested the import-mt.php script with a one post file. I added manually the commented post ID and it does indeed get imported into WP without being stripped.
However, I’m having trouble with your haloscan script. I wasn’t real clear where the haloscan export.xml file should reside. I tried in the same directory as the import script (wp-admin), then I tried the blog root. Neither worked. I confirmed that the commented ID number existed in the export.xml file along with its text. Zero comments imported.
Any thoughts?
import-haloscan.php looks for the export.xml file in the root wordpress directory, which is one level above wp-admin.
assuming the thread id’s in your export.xml file match the post id’s that you’ve enclosed in HTML comments at the beginning of the bodies of the posts you’ve imported in wordpress, you should be good to go.
note to self: include more informative error messages.
Justin, is it possible that Haloscan’s export format changed or something? If you don’t mind, I’m sending you a small one-post version of the files…
it only works for Haloscan users with upgraded accounts.
Rob, I’m not sure. I’ll take a look. I assume if the CAIF format changed, which is unlikely as it’s a standard outside of Haloscan, you’d see other telltale error messages.
Naeem, that’s correct. As I’ve noted above you would need to “donate” $12 to haloscan in order to upgrade your account and get access to your comments in the CAIF format.
Hi!
I’ll try and use your script as soon as I can, thanks for creating it!
One thing concerns me though.
I started using WP a couple of days ago. I have a blog that I manually updated via Dreamweaver and I’m actually uploading all the posts via cut/past and adjusting the timestamp (it’s almost three years worth of work, pray for me!) and I was wondering, will importing from haloscan work for me? Should I do something in particular to make it work or to link the comments to their “original” post?
Any help on the matter is much appreciated! :)
Thanks again!
So you were using Haloscan previously with a blog that you created manually with Dreamweaver?
Haloscan requires a unique post id in order to differentiate the comments for one post from another. If you were manually creating posts, were you giving each post a unique id in the haloscan link code? If so, then just make sure the unique id for each post is enclosed in an HTML comment at the beginning of every wordpress post.
Your script has worked great. I’ve had to do a lot of manual editing to prepare my import file (thank God for TextWrangler and regular expressions!), but it was worth it. Thanks again!
Rob, great, glad to hear it.
I had to use the famous “alternate method” instead of the one-line code above to import my Blogger posts.
so now the haloscan script always shows zero…is there a work-around? Thanks
whfropera, can you include more detail? the method you linked to was intended for importing blogger’s native commenting system. the instructions above are for importing haloscan comments from blogger to wordpress. which are you trying to accomplish?
thanks for the quick response! I am trying to import the Haloscan comments into the WordPress installation with the posts already in there.
(quote)the method you linked to was intended for importing blogger’s native commenting system.(endquote)
actually, it primarily is meant to import the posts – it was the ONLY method that would import the posts – I tried the FTP version for hours on Sunday and Monday, and Blogger never moved past 0%. This way also includes the Blogger comments, the blog I’m moving happened to primarily use Haloscan and not Blogger.
My problem now is that this blog has 6,000 comments all in xml export files, and I have no clue how to get those in to WordPress.
Thanks in advance for any help… :)
so you used the “alternate template” on the page you linked to–where you have to manually save and upload each archive file?
would it be conceivable for you to do the “alternative template” process again if i made a minor change to that template that would enable you to import your haloscan comments?
yes yes yes!! I have all the design tweaks backed up. :)
alright, i’ve uploaded a modified version of skeltoac’s alternate template:
skeltoac-blogger-template-for-haloscan-import.txt
all i’ve added was
<!--<$BlogItemNumber$>-->
to the beginning of the post body which is something that my import-haloscan script needs in order to relate your existing haloscan comments to your new wordpress posts.
use this modified template with skeltoac’s instructions to import your blogger blog to wordpress, and then follow my instructions above starting with importing your haloscan comments.
let me know (or send email) if you have any questions.
justin – at what snail mail address are you accepting gifts?
That worked perfectly – :)
Many, many thanks.
-wod
wonderful! i’m glad it worked. gifts are wholly unnecessary. but if you’re serious send me an email and i’ll pass along a mailing address.
Proactive support–who would have thought of it? Through a Google search, Justin found a post I’d made on my site mentioning that I was giving up on HaloScan after my move to WordPress. He sent me a link to this page and created a second script (see “Update:” above) for those of us who had already imported from Blogger without fixing the IDs first. The script (and the whole process) works great. Thanks!
tom, so glad to hear it worked out for you!
and for everyone else, i updated the post with a utility called “insert-blogger-post-ids” that you can run if you’ve already imported your blogger posts with the standard import-blogger.php script. then you’ll be able to import your haloscan comments with the import-haloscan.php script i wrote (available above).
Justin, I found a “bug” in the process of moving my Haloscan comments into WordPress. Not a bug really, but something for everyone to be very aware of!
Have a look at my new WP blog and pay special attention to the URL links of the commenters.
See how that’s screwed up? Those links show up the same way, even in the admin panel. Turns out, those links were originally entered by the commenter without the prefix “http://”, and as such, I guess WP freak out about it.
I’ve experimented with adding a new comment without the prefix, but WP seems to prepend the prefix automatically.
So again, kiddies, after exporting your haloscan comments, do a simple search and replace on the XML file and add the prefix. Using regex would be best. I use TextWrangler for my regex needs and something like this search string should work:
(“www\..*\….”)
replace with:
http://\1
Mostly for Google’s sake: this script can also import comments into WordPress from the BlogBack commenting system, because BlogBack exports to XML/CAIF.
Many thanks, Justin, for publishing this script.
Some people have been having problems with the import-blogger script being unresponsive. You may read about it here. The solution I found was a stripped down version created by a guy named Brad, as I mentioned in the WP Support post I linked to above.
Anyway, I am now having the same problem with your script (I had hand entered every ID number before trying to run it). I was wondering if you would try creating a stripped-down version of your script as Brad had done with the import-blogger script, maybe that would work for me. I don’t know enough php to do it myself.
Thank you very much!
Valerie, I assume something changed between 1.5.1.2 and 1.5.2 that broke the importers. Can you send me an email and I’ll send you some updated code that you can try out for me? If it works, then I’ll post the updated code here.
Thanks to Valerie’s valiant testing, I updated the import-haloscan.php script to play nice with WordPress 1.5.2 (which should continue to work with earlier 1.5.1 versions).
The word on the street is that the import-blogger.php script that ships with WordPress may be similiarly busted, in which case, replace lines 3-17 with the following line of code:
$action = $_REQUEST['action'];
i’m sorry, but i don’t get this whole thing. can my comments still be saved and exported to other comment system? you know, with blogback closing and all?
runi, I’m not familiar with Blogback, but people have described being able to export their Blogback comments in the CAIF xml format and then being able to use my scripts above to import them into WordPress.
Justin, I’ve done all you’ve instructed but I’m still getting “Imported 0 comments”.
I wonder if this could have had anything to do with it: I’ve imported my posts from Blogger and followed all the steps for a normal migration. Everything worked but I republished my blog to the wrong directory. So, I re-checked all my settings, and then republished to the correct directory. However, the publish stopped at 28%. So, I figured, what’s the difference? And I moved the files within my server, then I had previously put in the wrong folder. I finished the migration as normal and everything has worked fine… except your Halsocan import script.
Could my jerry-rig have affected that?
Jonathon, your comment that you “followed all the steps for a normal migration” is a red flag.
The Haloscan import process will not work unless you modify the Blogger migration process so that the Blogger post ids are stored in each new WordPress post inside an HTML comment. If you have not done this, then try my insert-blogger-post-ids.zip script to insert those post ids into your migrated posts, before retrying the Haloscan import script.
This will only work if you’ve still got the exported Blogger post files hanging around. If anything has been deleted or moved around or published to the wrong directory, then all bets are off, and I’d suggest starting over from scratch—making sure to follow each step above very carefully.
Feel free to send me an email if you continue to have problems.
Yeah… sorry that was a problem of semantecs. What I meant was that I did follow the updated blogger import process, with tags ids. I only said that because someone else specified they had done it manually.
Anyway… I’m thinking I won’t bother importing my comments. Haloscan seems to have only kept comments on record for the last 3 months or so, because anything older than that has dissapeared. So… losing just a handful of comments is not the biggest deal. Thanks for your time though.
I first did Andy’s migration scripts but didn’t get my Haloscan comments. I then reset everything to as was, and followed your instructions, Justin.
But I get the result message that 8 comments were successfully imported, when in fact there should be 442.
I paid up my $12 to Haloscan way way back, so that shouldn’t be the source of the problem.
Any ideas?
One main thing I was looking at a move to WordPress was to import my previous postings and Haloscan comments. If you plan on purchasing a domain and moving to wordpress from blogger, Justin has a post on importing Blogger posts and Haloscan comments.
[…] Now I hope I haven’t turned you off to migrating. There were some technical hurdles to overcome, but mine was a somewhat unique case where I had to combine a couple of workarounds. If you have been using Bloggers native comments, the process will probably be much smoother for you. The same is probably true for Haloscan comments. Also, if you have a newer blog with only a few backlinks, the permalink issue probably isn’t as important. At the same time, I wanted to highlight that it might not be a smooth transition and there might be things to overcome. Even with my problems, it only took me about 5 hours to do everything. And that includes virtually no knowledge of PHP, but some knowledge of working with databases.
Does this work with WordPress 2.0? I imported all my Blogger content easily but the script runs and doesn’t import any of the Haloscan comments.
Andy, I have not yet tried the Haloscan import with WordPress 2.0. Hope to do so sometime soon, but I’m not sure when. I tried to leave a comment on your blog but seemed not to be able. Send me an email if you’d like to work on this over IM sometime.
I currently can get my haloscan comments via RSS. would it be possible to import them to wordpress using this method and avoid paying the $12?
J, nope. The RSS feed of your Haloscan comments only shows the most recent 10 comments. You’ll need to pay the $12 to get access to all your comments in the CAIF export format.
Damn! Foiled!
Thanks for the speedy response justin!
[…] For those of you that want to do the same, WordPress does offer a free service (WordPress.com), and they do make it more-or-less easy to move both your posts and Blogger comments over to WordPress (whether it’s the free one at WordPress.com or the host-your-own, full-featured one at WordPress.org). For those with the paid version of HaloScan, you can import your old comments too – check here for directions before starting importing your BlogSpot blog. A couple words of caution: […]
Hasn’t worked yet, but I may go back and delete my blogger posts and try again. No sweat. Just reported 0 comments imported… Done.
[…] I seem to have “broken” my Blogspot version of twc while attempting (and failing!) to import my Haloscan comments as per these instructions. Was going to post some “Looky over here!” kinda stuff… and can’t get it to display any more. […]
[…] (à propos on PEUT réimporter les commentaires Haloscan ! Ca veut donc dire que si les accents passaient dans AgitProp, on pourrait tout réintégrer ici : knock on wook). […]
Gracias por tu guia fue de mucha ayuda.
Saludos.
Thanks for you guide it was really useful.
From Ecuador.
[…] Tout a l’air de fonctionner, les articles sont tous importés…sauf…les commentaires. Je n’ai pas réussi à importer les commentaires depuis Haloscan que j’utilisais sur le précédent blog. Une procédure existe mais elle n’a pas fonctionné. Je crois que je vais donc laisser tomber…Je suis désolé pour tous ceux qui ont pris du temps à les taper Je vais tenter de les récupérer d’une autre manière…mais d’après ce que je comprends dans la procédure, c’est trop tard car Haloscan n’arrivera pas à relier les bons comments aux bons posts. […]
I just tried out the importer in WP 2.0.1 There are still potentially some bugs (I don’t see posts actually showing that they have comments yet, though they do). One thing you have to do from the beginning is upload an older version of import-blogger.php. The new one is totally different. Before you do that, edit the “switch ($action)” line to read “switch ($_REQUEST[‘action’])” instead. I’m not sure why that syntax lasted through WP 1.5, but it’s there. If you use any of the older files (e.g. insert-blogger-post-ids.zip), you’ll need to edit them the same way.
Thanks for your guide!
I’ve imported blogger posts to WP 2.01 w/o a problem. Just import via the WP interface, then follow the steps given insert-blogger-post-ids.zip, i.e. output archives in root folder, etc. Then apply the haloscan steps. Works beautifully. The only problem I’m having now is that the comments exist and can be seen but the number of comments says “0 comments” everywhere instead of the “3 comments,” etc. Any solution to this?
amc, in WP 2.x, comment counts are cached in the posts table, which my script (originally written for WP 1.5x but in need of upgrade) neglects to update.
Rawlinson has written a script to update WP 2.x comment counts, and when I have a chance I’ll work to update my script to check for this.
I wrote one too. Though it’s far from elegant, it does work.
http://www.gradin.com/wp_201_recount_posts.php
*Very* straight-forward MySQL statements – not particularly abstracted, so it should be easy to tweak if need be.
Thanks for the import script. I moved a fairly large blogger blog to WordPress 2 without issue using the directions in this post and Olaf’s update comment count script. The one thing I would add is there is a very simple mod to the blogger.php wordpress import script that takes care of step 7. In the wp-admin/import/blogger.php file I added the commented Blogger item number before the BlogItemBody tag and was able to use import-haloscan.php w/out additional steps.
Thanks for taking the time to create these scripts. I’ve done everything as directed, but the insert-blogger-post-ids.php script doesn’t seem to want to work for me. When I click the OK button, the page just refreshes to the same page I was on. There is no evidence of anything else going on. Does this script not work in the lastst versions of Firefox or Safari for Mac OS X Tiger? I may have to try this on a PC at work.
Hmm, Smivey, if you want to dig into this sometime, send me an email.
Smivey et al, I’ve revised this post and the scripts available here to make sure that they all work correctly in WordPress 2.x. Hope that helps.
I can attest to the fact that the WordPress Suicide plug-in and the tweak to the blogger.php script work perfectly. Still having trouble with the final import-haloscan step. Might have something to do with the fact that I have so many Haloscan comments to import (three files’ worth). Or maybe I’m just doing something stupid (most likely). Whatever it is, I got his error when I ran the script: XML error: not well-formed (invalid token) at line 3283. Whatever that means.
Smivey, what that error message means is that there’s an XML error somewhere in one of your export.xml files at line 3238. If no comments got imported, it’s probably in export1.xml. This could be an invalid character (most likely), or an unclosed tag.
Fixing it should be pretty easy, just peek in the files and scroll to that line and see if you can find the error, fix it, and then try the import again.
Alternatively, you can open the files in Firefox or IE and their XML parsers will help to indentify the error, e.g. just go to:
http://www.example.com/wordpress/export1.xml
where example.com is your webserver. Firefox is particularly informative at ferreting out these types of errors.
OK, Justin already knows this, but the XML error was in one of the Haloscan comments. If anyone encounters this error, I recommend dropping the XML file into Firefox. It quickly pointed out the error for me. No problem. Thanks again, Justin.
[…] Justinsomnia’s Importing Haloscan and Blogger Comments Into WordPress […]
[…] A lot of the information I gathered were from the WordPress website itself but the more important stuff regarding importing Haloscan comments came from Justin (a million thanks Justin!). I will be providing links to his page when necessary as he has done a lot of the hard work on this bit. […]
Thank you for writing this, Justin. It works for me up until the final importing stage for the comments. I get this message:
The importer is running…
Warning: Invalid argument supplied for foreach() in /home/standupa/public_html/blog/wp-admin/import-haloscan.php on line 81
Done. 0 comments imported.
Completed Haloscan to WordPress import!
Now you can go and log in, have fun!
I don’t know how to fix it. Any help would appreciated.
(I am thinking that it might have something to do with a Haloscan beta feature I signed up with. It gives actual post titles instead of the numbers.)
[…] Save this file. Now head over to Justin’s page and download his import-haloscan-script.zip (version 2.0 at the time of writing) which can be located further down the page (in step 3). Extract the file and copy import-haloscan.php to your wordpress/wp-admin/import/ folder. […]
[…] Download Justin’s PHP script here; […]
I followed every step, exactly as you stated, but when I follow the final step, it completes the import with 0 posts imported.
Just curious, but in the “kill” option, you had us change the code From:
$post_content = $postinfo[2];
to
$post_content = “
Kyle, looks like not all of your comment came through. I’m also not sure what you mean by the “kill” option.
Shoot me an email and I’d be happy to give you a hand.
I posted awhile back about a problem I had been having, but I just tried it again (my 5th time, probably) and it worked! Thanks Justin!
Hi,
First, thanks for a very informative post!
Only problem is that I have already imported everything from my blogger blog to wordpress 2.x blog. Do I have to delete everything and then reimport for this to work?
Thanks,
Dave
Um ignore that…my bad
Dave, as you probably discovered in my post:
Best of luck!
Yeh, sorry, that was what the “my bad” was about! :-P
Unfortunately I seem to be having no luck…I have the export.xml file in the root of wordpress and the php file in the right spot but when I run it it tells me it has run but that I have 0 comments imported. The xml file definitely has data in it…any ideas?
Thanks!
Dave
Dave, bummer. Well send me an email if you want help troubleshooting this further.
Hi Justin,
Sorry to be pestilent but just wondering if you got my email?
Thanks,
dave
Thanks for all your help, Justin! Everything has come across perfectly :-)
Now I have no excuse not to start blogging again lol
I have tried to export my haloscan comments. When I log in to haloscan and select export, only one comment shows up, a test one I made a while back. Am I doing something wrong? All the halscan comments are still on my blogger site, I just can’t get to them :(
Kimmy, that’s a problem I’ve not heard of people experiencing before. The only thing I can guess is that you have multiple Haloscan user accounts and you’ve logged in using the wrong one.
The way you can confirm you’ve got the correct account is by looking at the line of javascript in your blog’s html source:
and make sure “yourusername” is the user name you’re using to log in. If that doesn’t help straighten things out, I’d contact the folks at Haloscan.
Thanks for creating this valuable resource. It worked great! One suggestion is to clarify step 3, part five. It took me a few minutes to realize that the export file from Haloscan goes in this directory: /wp-admin/import/. Other then that it was fantastic.
Justin Thank you so much for your response. I figured it out I have two different haloscan ids LOL Now I followed your instructions to a T but when I click OK it still says “0 imported” — Am I missing a step?
One more ? — Where is the export.xml file referenced? Am I supposed to edit code pointing to that file? Maybe that’s why they are not showing up?
Kimmy, the export.xml file should be uploaded to /path/to/wordpress/ and the import-haloscan.php file should be uploaded to /path/to/wordpress/wp-admin/ where “path/to/wordpress” in both cases is replaced with the actual path to your wordpress install (note: those are different directories).
[…] Importing Haloscan comments into WordPress from Blogger […]
Hey Justin, I never got my comments over, but no biggy. I have a much bigger issue I was wondering if you could help me with. I was trying to rearrange my sidebar and messed it up completely! Could you take a look and see what I might have done?
Thanks in advance! :)
Kimmy
Justin, I just want to thank you for this very helpful documentation! I followed your steps carefully (including having to use WP Suicide), and it all worked flawlessly!!! I am amazed at how easy you made this task. Kudos!
Kimmy, the problem is probably a misplaced closing tag. Unfortunately many CSS-based layouts have become so complex that moving things around may have unforeseen consequences.
I’d try to contact the author of the theme to see if s/he can provide some support. Or you might want to revert back to an original version of the theme and reimplement your modifications.
SJ, many thanks for comment, you’re very welcome. Glad to hear the process worked out so well for you.
Hi!
I´ve done everything you “asked”, but i´m getting this error:
“The importer is running…
XML error: no element found at line 8144 ”
Could you help me?
tks,
Michelle
Michelle, if you scroll down line 8144 in your export.xml file (using a text editor with line numbers), I assume there’s probably some garbled character in a comment that needs to be deleted in order for the importer to process the file. Let me know if you need any further assistance with this.
Wow, Justin, real time help! ;c))
I´ve changed what was missing on line 8144. Now, i get this:
XML error: not well-formed (invalid token) at line 1
:C((
Justin, you wont believe! I´ve checked my blog now and every comment was imported 7 times, probably the same number of times i´ve tried to import and got that errors… :c( Is there a way to start all over again and delete the coments?
Thanks for your patience!
Michelle, I’ve also written a plugin called WordPress Suicide which you can use to selectively delete your posts, comments, categories, etc. Be very carefully when using it, as it is set up to flush your entire blog by default. Before you run it, uncheck all the checkboxes except for the wp_comment one, and you’ll only delete your duplicate imported comments and be able to start the importer again.
As for the “not well-formed (invalid token) at line 1” error, maybe a newline crept into the beginning of your export.xml file?
I´ll try it later, thank you! But when i delete the wp-comments my WordPress comments (the brand new ones) won´t be also deleted?
Thanks! I’m in the process of moving from blogger to wordpress and everything worked extremely well for my 860 post 1024 comment blog. I was having so much trouble using other formats for it, involving way more tweaking than conceivable.
Michelle, yes, any new comments that have been left since you attempted to import the old comments would also be deleted using WordPress Suicide. If there are only a few, perhaps you could back them up manually (cut and paste)?
astrocoz, glad you found this helpful.
Yeah, I think I’m screwed.
I ported over a few months back and it was a nightmare…I can’t imagine blowing away all those posts to try again and make the connection.
Any other utilities out there I can try that won’t require this?
MsX, are you Michelle? Well, since the erroneously added comments were probably all imported at the same time, if you have command line mysql access/experience you could find the first and last ids of the comments you want to delete and use the following delete query to delete that range:
where you replace X and Y with the start and end ids of the comments you want to kill.
I’ve used this script tons of times for my clients moving from Blogger to WP and it’s always worked great. But now I have a client who has been using haloscan comments in WordPress (instead of using WP comments…I have no idea why) but she’s decided she wants to stop using haloscan. Can I use this to import her comments into WordPress? Or does it only work right after a blogger import? I actaully tried it just to see, but it didn’t import any comments. Maybe there’s some modifications I can make to the script to get it to work? Any thoughts?
I don’t use blogger, I’m just on WordPress and had to reinstall. Is there any way this could possibly work for me?
Zach, I’m not sure what you need. Were you using Haloscan comments with WordPress before your reinstallation?
That’s right. I had a WP blog with HS comments, then my server went down and I lost it all. So I reinstalled WP and now I would like to get the HS comments on it. If there’s a way to do that, spiffy, though I have a feeling identifying which posts go with which comments will prove difficult.
Zach, when you got your WordPress blog back online, where did the data from the posts come from? Were the WordPress post IDs no longer the same?
Basically, the import-haloscan.php script works by grabbing the old post ID from within an HTML comment at the very beginning of the post content, e.g.
<!--394-->So the other day I was...
It’s this old post ID (presumably from Blogger, but it could come from any blogging tool, in your could from WordPress itself) that Haloscan uses to link specific comments with posts.
If your new post ids are different, then you can still use the importer if you find a way to add the old post ids to the new posts using the HTML comment method I described above. Then just download your comments from Haloscan, run import-haloscan.php, and you should be off to the races.
Clear as mud?
Hmm, sounds plausible. Might take some work, given the fact that I have around 700 posts, but it’s somethin’. Maybe I’ll just do some small chunks or somesuch.
Zach, of course if there’s some other way to link up the posts, or if you could reimport the content so it maintains the ID, then you could spare yourself the pain of manually associating them.
For instance if you had a spreadsheet with two columns, one for the old ID, one for the new one, I could write a script that automatically inserts the old ID into the new posts so that the import-haloscan.php script would work.
I’m having the same issue as Zach here. I tried editing index.php to create the post ID comment, like this, but it still won’t work. No error message, just 0 comments imported. Can you help?
Thanks so much.
Jeffrey, you need your old Blogger post ids embedded in HTML comments (not the WordPress post_IDs) and saved in the wp_posts.post_content database field. You can only accomplish this by modifying the blogger.php import script per the instructions in this post.
If you’ve already imported from Blogger, you’ll need to start over again by deleting all your imported content with my WordPress Suicide plugin, modifying the blogger.php import script, and rerunning it.
Justin
Unfortunately, I never came from Blogger. I was using Haloscan comments with a standalone WordPress install because I was raking in too much comment spam! I think I might be stuck…
Jeffrey, I understand now. As long as your WordPress post IDs haven’t changed, you’re actually in the enviable position of not having to worry about old Blogger ids (and the hack of embedding them into the WordPress post content).
But in order to import your Haloscan comments into WordPress, you’ll need to edit the import-haloscan.php script.
In a text editor other than Notepad, open import-haloscan.php (v2.0) and replace lines 86 through 96 with:
Save the file, upload it to your /path/to/wordpress/wp-admin/ directory, and rerun the script. Feel free to let me know how it goes.
Thanks, Justin! It worked like a charm. I know there are going to be other people out there who are having this same problem… not any more!
[…] I started using Blogger before they had a comments feature. So I implemented Haloscan comments on my site. That was awesome because there is a certain amount of satisfaction of having feedback from your readers. But that also meant that I had to combine data from a couple different sources when moving into this set-up. Not a problem with a plugin from Justinsomnia. […]
Is there anyway to use this to import Blogger posts (not bothered about comments) to a specific category in a WordPress blog?
when i imported my Blogger posts into wordpress my photos didn’t come with it…is there something i can do to have them appear besides uploading all of them again?
Gordon, nope, this script doesn’t so anything for inporting into a specific category, though it wouldn’t be very hard to write a script to do so (if something like that doesn’t already exist). Feel free to send me an email if you need help doing this.
Jackie, in order for Blogger to prevent image hotlinking (aka bandwidth mooching) they will not serve your images if they appear to be requested from a non-blogspot blog—as is now the case since you’ve imported your posts to wordpress.com.
So for example, your recent post The Ancient Ruins of Kuau’a has four images in it, but Blogger is refusing to display them. However, if you paste the URLs for the images directly into your browser, you’ll be able to see them again, e.g.
Unfortunately this mean that yes, you’ll have to re-upload them to WordPress and update all your existing posts to the new location. Luckily your blog only goes back to August, so it shouldn’t be too hard to do.
Jackie, you have a Blogger Image Import Plugin and it works perfectly! (It checks your WP posts with blogger images, download the images and updates your posts)
Works works!! I helped a friend of mine from New Jersey who showed me your site and we made it work.
Thank you!
[…] I use that several steps so I have some backup if something goes wrong. Although all posts are imported, but not all the comments are imported. The comments that are using Haloscan services can’t be imported. Yes, there is a way to import them, but it cost some money […]
[…] Siguiendo las indicaciones que amablemente nos ofrecen desde Justinsomnia.org (aquí y aquí) procedemos a modificar el fichero blogger.php que se encuentra en el directorio wp-admin/import/ de tu instalación de WordPress. […]
I dont understand this can help me
(i dont can English but i can German)
i am 11 Years old
Aalijah, your blog already uses WordPress, which is good. Do you need help importing comments from Haloscan? Here is this webpage translated into German. I hope this helps.
Aalijah, dein blog verwendet bereits WordPress, das gut ist. du benötigen helfen, Anmerkungen von Haloscan zu importieren? Ist hier diese Webseite, die in Deutschen übersetzt wird. Ich hoffe, daß dieses hilft.
[…] Haloscan friendly: this option will cause your posts to have comment fields (invisible) for this Haloscan importer to work. […]
thx Justin
It has me very helped!!!!!!!
Does this Blog belong to you????
Already or?
Love of greetings!!!
Aalijah
[…] If you’re using Haloscan comment in blogger, then enable the option and use the plugin in conjunction with this. […]
Hi! Thanks for doing this script.
One slight problem is I’m getting an error reading “XML error: Invalid character at line 6082”. However, Firefox doesn’t pick up any XML errors in the file, and all there appears to be at line 6082 is a line break (^M). The first export file is at http://www.confessingevangelical.com/export1.xml
Am I correct in assuming that these instructions are if you are importing comments to WordPress, but not to a WordPress.com blog? I’m not using WordPress.org, but the free blogs at WordPress.com. It does not allow me to upload plug-ins. Do you know of anyway to import Haloscan comments to WordPress.com? thanks for any assistance you may be able to provide.
Wanda you are correct, this procedure does not work if you are hosting your blog with WordPress.com (rather than installing WordPress in your own webspace).
I have to add that installing WordPress in your own webspace is quite easy, especially if you choose Dreamhost. I’ve written up instructions on How to manage a self-hosted WordPress blog from Windows from Dreamhost (if you’re interested). The benefits are freedom plus you get to pick your own domain name The downside is it costs $10/month (not to shabby in my opinion).
Is there a method to convert my blogger blog to wordpress :S
Regards
nakliyat, check out Importing Content on the WordPress Codex.
Hi Justin, I have a haloscan comments to import to wordpress but it’s not Blogger base. I previously did a simple post in my website linking to haloscan. Any advise how to transfer them?
Hi Justin, I’ve tried putting the html comment code in front of every wordpress post but it didn’t work. Can you help me?
Am I out of luck importing my Haloscan comments if I use WordPress.com?
Jonathan, afaik, yep.
There’s been some changes with the Blogger import in WP 2.1.1 so Step 2 is no longer possible. However, after doing some digging, isn’t it easier to simply go into your Blogger template and add the following just before where the body text would appear:
This will automatically insert the Blogger entry ID which accomplishes the same in step 2.
I’m currently moving a Blogger hosted blog w/ Haloscan to WordPress 2.1 as I type this.
Cent, I’m not sure because I’m assuming the new importer grabs the content directly from their DB without filtering it through your template. I could be wrong of course. If this works for you, could you please report back here? Thanks.
I have been using Haloscan with my WordPress blog (don’t ask why…) and now I have shifted over to WordPress comments. I can’t get the Haloscan import tool to bring the comments over. I follow all the steps, run the tool and it states that 0 comments have been moved. Will this not work for my application?
what line in 2.2.1?
This is wonderfully helpful, except I seem to be caught in a catch 22. I couldn’t import my New Blogger posts until I upgraded to WP 2.2, and now the line of code you specify doesn’t appear in the blogger.php file anymore. Thoughts? I’ve got nearly 10K haloscan comments and would hate to lose them!
Looking for help setting up wordpress at http://www.askhelpdesq.com especially with auto-update feature. (So daily calendar of new items can be imported). Thanks.
Hello. I am trying to use the haloscan importer and when I run it I get the following error:
XML error: Invalid character at line 5969
I looked at that line in export.xml and it is a simple email address. Any thoughts?
Justin, I’m using WP 2.2.2, and tried to implement your “old” instructions (Step 2A), since step 2 no longer works. That didnt work.
Next I tried Cent’s suggestion, although I can’t see the code he entered, it seems it got commented out.
So I inserted $BlogItemNumber$ inside of a comment wrapper, published it all to a blogspot address that I created for the move.
The import in WP dashboard worked fine.
I joined haloscan, exported 2 files, then tried to run the haloscan importer with no luck. I scanned the code, and it SEEMS like that should work, but it hasn’t.
Any more suggestions? Thanks
docshazam AT msn.com
Justin, the problem with the method I used above is that the wordpress blogger importer script does not import the blogger post ID comment string. So this would require an additional change to the blogger importing script. Hmm. I’m not great at PHP, but I’ll keep looking.
So near and so far. I inserted the blogger post ID manually into a wordpress post after importing, then ran the haloscan importer and it worked! ButI can’t get the blogger import script to see the blogger post id comment. So I could manually isnert 800 blogger ids, which whill be twice as fast as manually inserting 1600 comments. It’d be nice to solve this puzzle, and I think it lies with a new line of code for the blogger.php for 2.2.2
what line 2.2.1?
it only works for Haloscan users with upgraded accounts
To everyone who has unsuccessfully tried to import their Haloscan comments since the new version of Blogger (supported in WP 2.3), my apologies, I just haven’t had the time to update this post…until now.
You can check out the updated version of these instructions here: Importing Haloscan comments into WordPress 2.3 from Blogger. Good luck!