If you were using Blogger for your blog and have finally decided to migrate to WordPress, you maybe wondering how will you migrate the Facebook comments of your blog readers to your new blog. This tutorial shows exactly how to do that.
Finally my blog’s migration is over, and now I have a sense of relief. This blog was started two years ago, first was a WordPress.com site, then migrated to Blogger. I kept using Blogger for sometime, but there were many reasons after which I decided to finally give WordPress a try. So took a day off, and migrated all my content, posts, pages and comments from Blogger to this self-hosted wordpress blog. And I didn’t lose my Google Page Rank in the process by following this tutorial, and finally my users can enjoy a fresh new blog in faster servers :-D.
The migration was easy as I got all the posts and comments, however, there was a unique problem that I didn’t find a solution elsewhere in the web. I used to use Facebook comments in my blog and there were a good number of comments that I was going to lose if not migrated. Sure, there were a good number of WordPress plugins that allow you to integrate Facebook comments in your blog, but none of them offered migration of comments from Blogger. So I looked a bit of Facebook API, hacked a bit of code, and migrated all the comments without needing a plugin. And here in this tutorial, I will show you exactly how to do so.
First of all, I recommend that you backup your WordPress blog, both the files and the database using a good plugin. Integrating Facebook comments will require editing some WordPress core files, so if anything goes wrong and you need to roll back to earlier state, you can restore the things from backup. Also, please note that the URL structure of your posts need to be the same as they were in Blogger, else the comments will not load. I gave a link to a tutorial of WordPress migration before, the tutorial shows exactly how to do so.
Now, let the hacking begin.
Select your application and copy the code from
<div id="fb-root"></div> to
</script>. Now go to your WordPress admin interface and navigate to Appearance > Editor. Click on the file Header (header. php) and paste the code just after the beginning of tag. Be careful, do not affect any other code.
You may also need to add the fb-admin tag for moderating facebook comments, though thats strictly not necessary. Just after the head tag opens, place this code. Make sure your place your application ID in appropriate place.
<meta property="fb:app_id" content="your app id"/>
When done, click on Update File.
Now the SDK is loaded, we just need to insert the code which will allow us to load the facebook comments in the page. For that, we need a minor edit in a page. From the templates list in the right sidebar, click in the file Single Post (single.php). From your browser’s find function (Control+F), find this code: php get_template_part( ‘content’, get_post_format() ); ?>.
Add the following code just after that line.
You may adjust the data-width according to the theme of your webpage, but make sure that other codes remain the same. Now navigate to the top of the file and just after
get_header(); ?>, add the following PHP function.
When done, just click on Update file. You have successfully integrated and migrated Facebook comments in your WordPress blog.
I have integrated Facebook comments on my blog, as you can see below using the above method. This is tested to work with Twenty Twelve theme, though it will work with other themes also. If you are having problems migrating Facebook comments in your blog theme, just leave a comment below. I will be happy to help you.
In the next tutorial, I will show you how to integrate Facebook comment count beside the WordPress comment count, so it is the right time to like our facebook page and get all the updates.