How to display the number of your Facebook fans

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.

   Related Sponsored Links

Disclaimer: The information contained in this website is for general information purposes only and in no event will this site or its owners be liable for any losses or damages associated with your use of our site or content. Click here to see our full Disclaimer.

Leave a Comment

*