Showing the amount of subscribers you have on your RSS feed is great, especially if you have a great amount of loyal subscribers. The same can be said if you display your Twitter followers and Facebook fan page.
What if you could display these counters as text, instead of image or without the use of any javascript?
Well have you noticed my sidebar lately? I have added the number of people who has subscribed to my blog via RSS feed or RSS email.
Would you like to have this on your blog as well?
[box type=”important”]MUST Install Exec-PHP Plugin[/box]
In order for the counters to work on your blog then you MUST execute the PHP codes below. You can do the by installing the Exec-PHP WordPress plugin. The Exec-PHP plugin executes PHP code in posts, pages and text widgets.
So before you install these codes on your blog to display the counters, you firstly need to install the Exec-PHP WordPress plugin.
[box type=”red”]How To Display Feedburner Subscribers As Text[/box]
Copy the code below and paste it in your sidebar as a text widget where you want your Feedburner Subscribers counter to be displayed.
<?php function WM_fb_count ($fb_user) { $fburl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=". $fb_user; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $fburl); $stored = curl_exec($ch); curl_close($ch); $grid = new SimpleXMLElement($stored); $rsscount = $grid->feed->entry['circulation']+0; return number_format($rsscount); } function WM_fb_count_run($feed) { $fb_subs = WM_fb_count ($feed); $fb_option = "WM_fb_sub_value"; $fb_subscount = get_option($fb_option); if (is_null($fb_subs)) { return $fb_subscount; } else {update_option($fb_option, $fb_subs); return $fb_subs;} } function WM_fb_sub_value($feed) { echo WM_fb_count_run($feed); } ?>
Copy the code below and paste it under the code above (in the same widget).
Replace WebmasterSuccess with your Feedburner ID to have your Feedburner subscribers completed.
<?php WM_fb_sub_value('WebmasterSuccess'); ?>
[box type=”green”]How To Display Twitter Followers As Text[/box]
Copy the code below and paste it in your sidebar as a text widget where you want your Twitter Followers counter to be displayed.
<?php function WM_twitter_followers ($twitter_user) { $url="http://twitter.com/users/show.xml?screen_name=". $twitter_user; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); $xml = new SimpleXMLElement($data); $tw_fol_count = $xml->followers_count; if ($tw_fol_count == false) { echo '512'; } else { echo number_format($tw_fol_count); } } ?>
Copy the code below and paste it under the code above (in the same widget).
Replace BabyBoyKharim with your Twitter username.
<?php WM_twitter_followers ('BabyBoyKharim'); ?>
[box type=”blue”]How To Display Facebook Fan Page Counter As Text[/box]
Copy the code below and paste it in your sidebar as a text widget where you want your Facebook Fan Page counter to be displayed.
<?php // Get Facebook Fan Count // function WM_fb_fan_count($fb_id){ $count = get_transient('fan_count'); if ($count !== false) return $count; $count = 0; $data = wp_remote_get('http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id='.$fb_id.''); if (is_wp_error($data)) { return 'Error getting number'; }else{ $count = strip_tags($data[body]); } set_transient('fan_count', $count, 60*60*24); // 24 hour cache echo $count; } ?>
The image above shoes you how to get your Facebook fan page ID. This ID is required if you want to display the number of fans you have.
Replace the ID in the code below with your Facebook ID to display your counter.
Copy the code below and paste it under the code above (in the same widget).
<?php WM_fb_fan_count ('154784051207520'); ?>
[box]In Conclusion…[/box]
Displaying your counters in text rather than image will help to reduce the load time of your bog.
Please leave me comment and tell me how this works for you, or if you need further help installing your counters.
igor
Mahendra Yadav
Ayesha
Chris
Kharim Tomlinson
Graven
Kharim Tomlinson
Fisayo
Kharim Tomlinson
Beth
Kharim Tomlinson
Beth
Kharim Tomlinson
Abelate
Kharim Tomlinson
Marian
Kharim Tomlinson
Marian
Kharim Tomlinson
Megan Brown
Kharim Tomlinson