Setting Facebook comments web plugin

后端 未结 5 1282
南笙
南笙 2020-12-31 09:29

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?

相关标签:
5条回答
  • 2020-12-31 09:36

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

    0 讨论(0)
  • 2020-12-31 09:37

    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>
    
    0 讨论(0)
  • 2020-12-31 09:37

    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.

    0 讨论(0)
  • 2020-12-31 09:43

    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"
    0 讨论(0)
  • 2020-12-31 09:55

    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.

    0 讨论(0)
提交回复
热议问题