Add a Facebook Comment Box to Each Post / Page of Your WordPress Blog

By Jers in Wordpress tips

It is easy to add a facebook comment box on every post of your wordpress blog. All you have to do is to go to facebook comments plugin page and get your facebook comment box code. Paste the generated code on specific areas of your wordpress blog where you want the comment box to appear (usually at loop-single.php or single.php).

The code usually look like this, where example.com is the URL of your wordpress blog:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="example.com" num_posts="2" width="500"></fb:comments>

The problem with the above code is that all comments made by users will appear on each and every post on your blog making the comment irrelevant on other pages. To solve this, all you have to do is to add the permalink of each of your pages on the generated code.

How to Display Facebook Comment Box on Every Post

 

To do this, replace the above generated code with this:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="<?php the_permalink(); ?>" num_posts="2" width="500"></fb:comments>

Replacing the URL of your site to href=”<?php the_permalink(); ?>” will solve the above problem and comments on every post should appear on their respected pages.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>