Snippet: Get your number of Facebook fans

Add following code where you want to display your fans


<? echo get_my_fb_fans($my_page_id); ?>

Add following snippet to “functions.php”


function get_my_fb_fans($page_id) {
    $xml = @simplexml_load_file("".$page_id."") or die ("a lot");
    $fans = $xml->page->fan_count;
    return $fans;


Display number of fans your facebook page has on your website with this simplest function.

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>