Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Comments Plugin: How to sort the comments, newest first?

We are using the http://developers.facebook.com/docs/reference/plugins/comments/ Plugin for the comments on our website.

The comments the tool displays are sorted by the social "factor", i.e. much liked comments first etc.

I want to show the newest comments first, reverse chronological. I have no idea how to set this as the default for all our visitors.

I have found some ideas here: Facebook comments plugin - how to sort comments? Setting Facebook comments web plugin

However, noting of this seems to work anymore.

Do you have any idea what to do?

like image 650
Tes Taccount Avatar asked Mar 30 '12 12:03

Tes Taccount


2 Answers

I have seen a lot of answers to this, but only this one worked for me.

<div class="fb-comments" data-href="your-website" data-num-posts="5" data-width="638" data-order-by="reverse_time"></div>

So anyway the key thing to set is data-order-by="reverse_time".

like image 102
Nemanja Avatar answered Sep 28 '22 04:09

Nemanja


Well I did some research and found a solution that worked for me:

First of all, I took the generated code from Facebook, which you can get on: facebook comment plugin

Example:

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/de_DE/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

I put the div at the top of the body on the side I want the plugin to appear. You can put the script in the head or in an external JS-File.

After that, I put the 2nd part of the generated code in the place I want the Comments-Plugin to appear.

Example:

<div class="my_comments_plugin"
<div class="fb-comments" data-href="http://example.com" data-num-posts="2" data-width="470"></div>
</div>

Now the most important part: I then put another data-Attribute into the div with the class fb-comments:

data-sort-by="reverse_time"

Which makes the comments appear in a reverse chronological order!

Hope I helped!

like image 38
user1568514 Avatar answered Sep 28 '22 04:09

user1568514