Inspiration For Creative Minds
Home » Labs » Code for displaying number of Facebook fans in WordPress  

Filed under Labs

In order to display the number of Facebook fans in a WordPress site just copy and paste below code to your WordPress theme. Don’t forgot to change PAGE-ID to your Facebook fan page ID.

 
<?php 
 
$page_id = "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 ("oops");
    $fans = $xml->page->fan_count;
    echo $fans;
 
?>
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook
Labs

Posts you may like: