Display number of FaceBook fans in WordPress

Social media proof can be very effective in impressing new visitors. How to display number of FaceBook fans in WordPress blog or website? Just use the following code in WordPress template files (index.php, header.php, sidebar.php, footer.php, etc) to display the number of your FaceBook fans. Do not forget to replace “YOUR PAGE-ID” with your own Facebook Page-ID.

$page_id = "YOUR-PAGE-ID"; //Replace YOUR-PAGE-ID with actual FB 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;

Premium WordPress Themes

Reliable Web Hosting

Smart Web Worker strongly recommends HostGator for your website/blog hosting. Sign up for web hosting at just $3.96/month. Use the coupon code "SMARTBLOGGER25" to get 25% discount on any hosting packages. Get an account with HostGator now!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>