Setting Facebook comments web plugin

2019-02-06 08:15发布

问题:

The default sorting order of the facebook comments plugin is by social status. How do I set the default order to reverse chronological on my web page?

I know there is an option on the top of the plugin. But not all users know about it and the sorting order is confusing.

回答1:

Just guessing I added

 data-order-by="reverse_time"

to the div provided by Facebook and it worked nicely. So, loading the pluging with the standard html5 code provided here: https://developers.facebook.com/docs/reference/plugins/comments/

just add the data-order-by attribute like this:

<div class="fb-comments" data-href="YOUR_URL" data-width="470" data-num-posts="6" data-order-by="reverse_time"></div>


回答2:

I was googling a lot without success, so I solved this by some reverse engeneering...

  1. Use some browser code inspector to see which iframe was inserted by facebook javascript that adds the comments plugin into the page. Copy the facebook_crazy_url of that iframe (see step 2). The inserted iframe seems to be the only thing that is needed to run the comments properly
  2. Get rid of the FB javascript and insert your own iframe instead: set the url to "https://www.facebook.com/plugins/comments.php?channel_url=facebook_crazy_url&order_by=reverse_time"


回答3:

Another option inspired by Jan Turoň's solution:

  1. put your fb:comments in a div with id "comments":
    <div id="comments"><fb:comments ...></fb:comments></div>
  1. use jQuery to change the generated iframe's src:
    $('#comments iframe').attr('src', $('#comments iframe').attr('src') + '&order_by=reverse_time')

Of course, you can do this without jQuery.

It loads the comments' frame twice, but it works in all cases without harcoding the iframe's src.



回答4:

You cannot change the default sort order of the comments plugin. To achieve something like this, you could retrieve the comments yourself, e.g., using FQL, but then you need to build everything else, too. Or use something like Disqus.



回答5:

If you visit https://developers.facebook.com/tools/comments/{Your_app_id}/ and then click the Settings link, it will let you edit the "Sort Comments By" setting.

The choices are:

  • Top
  • Newest
  • Oldest

According to https://developers.facebook.com/docs/plugins/comments/#moderation-setup-instructions, your webpage must have a tag like <meta property="fb:app_id" content="{YOUR_APP_ID}" />.

P.S. Unfortunately for me, since I'm using ClickFunnels, adding this tag doesn't seem to have any effect. I would instead need to be in complete control of my webpage (and not use a simplified tool like ClickFunnels).