There are so many ways to Display Twitter Followers in Text, the popular way is we can use CURL method, we have writen the tutorial display twitter followers in text using CURL. But this method for some WordPress Developers said this method not safe, because some server didn’t have CURL.
So after we check the tips from ProBlogDesign that you can read it here many famous developer has reply this post. The most interesting part is Otto one of Plugin Developer said that this method didn’t good. And here give more better. Otto using default WordPress function get_transient(); and wp_remote_get().
Display Twitter Followers in Text using Transients API
Write this code on your functions.php theme files and save it
function get_twitter_count() {
// first check the transient
$count = get_transient('follower_count');
if ($count !== false) return $count;
// no count, so go get it
$count = 0;
$data = wp_remote_get('http://api.twitter.com/1/users/show.json?screen_name=WPTricksNet');
if (!is_wp_error($data)) {
$value = json_decode($data['body'],true);
$count = $value['followers_count'];
}
// set the cached value
set_transient('follower_count', $count, 60*60); // 1 hour cache
return $count;
}
Please notes, you need to change username on the request, we have put WPTricksNet, so you need to put your own username. Next, you need to put the code to call this functions on your sidebar.php or whatever you want put the counter.
<?php echo get_twitter_count(); ?>
If you want style the code you can make like this example
<div class="twcounter"><?php echo get_twitter_count(); ?></div>
And you need add some style on your style.css
.twcounter {
background: #89B6F8;
padding: 10px;
color: #194B96;
}
That’s it, now you have better ways to Display Twitter Followers in Text, photos from flickr
Useful Source:




Pingback: How To Display Twitter counter in Text # WordPress Tricks & Tips
Pingback: Tweets that mention The Better Way Display Twitter Followers in Text # WordPress Tricks & Tips -- Topsy.com
Pingback: Cara Menampilkan Jumlah Followers Twitter dengan Transients API
Pingback: How to show the number of Twitter followers you have in WordPress » Malcolm Coles
worked like a charm thanks! The one from problogdesign wouldn’t work for me. the function was never getting called.
OK, NOW THAT IS HELPFUL!!!
After slogging through all the over bloated apps, plugins and ugly buttons just to display the number of twitter followers this gave me just what I needed and nothing more. Now I can style my button around this output and make it just the way I like it. Thanks for saving my day.
Jim
Thanks for the codes, great tutorial I will try to figure out this and add my own functionality