Quantcast
Channel: WordPress Tips, Code Snippets, and How To Tutorials
Viewing all articles
Browse latest Browse all 27

How to display the number of your Facebook fans

$
0
0

Everybody knows that Facebook is a very valuable tool for any blogger. This WordPress tip will show you how to display the number of your Facebook fans count in your WordPress theme template file.

<?php
$page_id = "Facebook-Page_ID";
$xml = @simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot");
$fans = $xml->page->fan_count;
echo $fans;
?>

Add the code above inside your theme’s template files wherever you want the number of your Facebook fans displayed. You will need to replace Facebook-Page-ID with your Facebook page’s ID. Hope this helps, enjoy.


Viewing all articles
Browse latest Browse all 27

Trending Articles