Site icon CodeRevolution Knowledge Base

Display number of Facebook fans in full text on your WordPress blog – CodeRevolution

If you have a Facebook page for your blog, you might want to display how many fans you have. Today’s recipe will help you to get your Facebook fan count, in full text!

Simply paste the following code in any of your theme files, where you want your Facebook fan count to be displayed. Don’t forget to add your page ID on line 2!

 <?php 	$page_id = "YOUR 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; ?> 

Thanks to WP Snippets for the recipe!

Exit mobile version