Showing your Facebook page fan count in plain text could come as handy when you want to control the styling and dispplay of your Facebook page fan count without using any Facebook plugins.
The following code snippet will display your Facebook page fan count easily. You only need to place the code where you want to display the fan count in text format.
Display Facebook Page Fan Count using PHP
<?php /* Add this function to your functions.php */ function dt_facebook_fan_count( $page_id ) { $ch = curl_init("http://graph.facebook.com/$page_id"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $raw = curl_exec($ch); curl_close($ch); $data = json_decode($raw); $fans = $data->likes; return $fans; } /* Add this where you want to display the count */ echo dt_facebook_fan_count('YOUR_PAGE_ID'); ?>
Instructions
You just need to replace YOUR_PAGE_ID with your own Facebook page name or ID. That code will display your Facebook page fan count as a plain text.
The post Display Your Facebook Page Fan Count in Text appeared first on Deluxe Themes.