user1008545
user1008545

Reputation:

Facebook comment count acording to page

I have many facebook comment boxes on my website. All pages have separate comment box i want to display comment count on each page (Only that page comment count)

For that purpose
I have used many possible ways to get facebook comment count according to each page comment box but never succeeded

I used following ways

Method 1

   <div class="fb-comments-count" data-href="http://myWebsite.com/" xid="<?=$page_id?>">0</div>

Method 2

   <a class="fb-comments-count" xid="<?=$page_id?>">0</a>

Method 3

   <div class="fb-comments-count" id="comnt-count" data-href="http://myWebsit.com/<?=$page_id?>">0</div>

Method 4

   <div class="fb-comments-count" id="comnt-count" data-href="http://myWebsit.com/?xid=<?=$page_id?>">0</div>

Method 5

   <fb:comments-count xid="<?$page_id?>" href=http://example.com/></fb:comments-count>  

and

   <fb:comments-count href=http://example.com/?xid=<?$page_id?>></fb:comments-count>

Upvotes: 0

Views: 5254

Answers (2)

Anil
Anil

Reputation: 21910

Include the javascript SDK into your page..

// Include the facebook SDK (Replace the AppID with your appid)
(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/en_GB/all.js#xfbml=1&appId=xxxxxxxxxxxxxxx";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

The link provided above should work (But it will not validate under a HTML 5 template), use the following link If you have a html 5 template:

<div class="fb-comments-count" data-href="<?php echo get_permalink() ?>"></div>

Your page probably has 0 comments to start with, so 0 will be displayed inside the div.

Upvotes: 1

yussz712
yussz712

Reputation: 16

i use this simple code

<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count> Comment

you can see at my page www.ayamtube.com

Upvotes: 0

Related Questions