How to get Facebook comments count with HTML5?

I know two ways to retrieve the number of comments on Facebook:

<fb:comments-count href=></fb:comments-count> awesome comments 


<iframe src="" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:130px; height:16px;" allowTransparency="true"></iframe> 

But none is a semantics for HTML5 solution, is there any alternative?


You can also get HTML5 valid FB comment count this way:

<div class="fb-comments-count" data-href="/post URL">0</div>

FB automatically replaces the "0" with the correct number. If you put something there like "awesome comments", it will be replaced with the number of comments i.e. "13", etc.

In order to get the number and use your own text, do something like this:

<a href="/post URL"><div class="fb-comments-count" data-href="/post URL">0</div> awesome comments</a>

Notice you must wrap your class in div's or else the comment counter will not work.

Graph API example using jquery:

<script type="text/javascript" src=""></script>
<script type="text/javascript">

        url: '',
        dataType: 'jsonp',
        success: function(data) {
             alert("comments: " + data.comments);


Since v2.3, it can be handled by span, which already has the natively display: inline; semantics.

<a href="/post-link">
  <span class="fb-comments-count" data-href="/post-link">0</span> comments

For an wordpress post u can use like <fb:comments-count href=<?php the_permalink();?>></fb:comments-count> awesome comments

Need Your Help

ASP.MVC: Repository that reflects IQueryable but not Linq to SQL, DDD How To question

linq-to-sql repository domain-driven-design iqueryable

I want to create a DDD repository that returns IQueryable Entities that match the Linq to SQL underlying classes, minus any relations. I can easily return Entities minus the relations with a Linq ...

How can Meteor apps be tested?

testing meteor tdd

What are the recommended ways to test web applications developed with the meteor framework?