I want to display a FB comment box on every page but have their own comments specific to that page

Nickolas Shaffer picture Nickolas Shaffer · Jul 14, 2012 · Viewed 8.9k times · Source

I recently coded my own blog for a site im making. I want to use facebook to handle the comment on posts, so i integrated the plugin. I noticed something odd however. If i comment on one blog post, then go to a different one, my comment is on the other blog posts as well. How do i make it so each post has its own set of comments?

Answer

liliumdev picture liliumdev · Jul 14, 2012

You have to set a different data-href attribute for each post. Here's an example of how I do it in Yii:

<div class="fb-comments" data-href="http://domain.com/post/view/<? echo $model->id; ?>" data-num-posts="4" data-width="695"></div>

The point is the data-href value has to be unique for each post.