Setting Facebook comments web plugin

泄露秘密 提交于 2019-12-08 23:25:40

问题


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).



来源:https://stackoverflow.com/questions/7481765/setting-facebook-comments-web-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!