Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Like Count

I've successfully integrated a Facebook Like button to WordPress based website. The Facebook Like button is shown only on single posts. However, I would like to output how many times a post is being liked on the front page of my site without showing the actual like button. A simple number output is what I'm after.

I've been reading Facebook documentation as well some tutorials that partly deal with this issue, but haven't got anywhere so far.

like image 799
Metin Avatar asked Jun 05 '11 14:06

Metin


2 Answers

Paste this function in your theme functions.php file and save the file.

function bfan() {
    $pageID = 'Page ID/Page Vanity URL';
    $info = json_decode(file_get_contents('http://graph.facebook.com/' . $pageID));
    echo $info->likes;
}

Then you can call the function.

You will need to know your facebook page ID or facebook page name,then just substitute it in the code above.

Hope this helps you out.

like image 76
Llewellyn Collins Avatar answered Sep 21 '22 08:09

Llewellyn Collins


Facebook has an API for finding out how many Facebook shares (likes etc.) a page has:

http://graph.facebook.com/?ids=https://stackoverflow.com/

like image 33
ceejayoz Avatar answered Sep 25 '22 08:09

ceejayoz