Can anyone help me – how do you put those RSS (Feedburner) and Twitter follower count widgets on your site. I’d like to put that onto my side maybe as a Wordpress Plugin?
Hi Jeff,
I recently looked into this as well, although only have a working Twitter counter so far.
This is what I have so far:
Code in functions.php
// Use this function to retrieve the followers count
function my_followers_count($screen_name = 'twitter_name')
{
$key = 'my_followers_count_' . $screen_name;
// Let's see if we have a cached version
$followers_count = get_transient($key);
if ($followers_count !== false)
return $followers_count;
else
{
// If there's no cached version we ask Twitter
$response = wp_remote_get("http://api.twitter.com/1/users/show.json?screen_name={$screen_name}");
if (is_wp_error($response))
{
// In case Twitter is down we return the last successful count
return get_option($key);
}
else
{
// If everything's okay, parse the body and json_decode it
$json = json_decode(wp_remote_retrieve_body($response));
$count = $json->followers_count;
// Store the result in a transient, expires after 1 day
// Also store it as the last successful using update_option
set_transient($key, $count, 60*60*24);
update_option($key, $count);
return $count;
}
}
}
Then utilise this to post it in the template file:
<?php echo "I have " . my_followers_count('yourtwittername') . " followers"; ?>
I cannot remember which tutorial i found it from as my browser crashed.
EDIT : Link to tutorial http://kovshenin.com/archives/twitter-followers-count-snippet-for-wordpress/Thanks man. I see themes on here with it on but the one I purchased – as awesome as it is – doesn’t ahve it, I don’t really want to buy a whole new theme just to get that little bit.
jeffeatworld said
Thanks man. I see themes on here with it on but the one I purchased – as awesome as it is – doesn’t ahve it, I don’t really want to buy a whole new theme just to get that little bit.
search the wordpress.org plugin repo, there are a handful thatll do what you want
Cheers – I’m thinking something like this would do it but I’ve no idea how to integrate this – do I just put this into my sidebar.php file or wherever I want to show it?
http://codecanyon.net/item/socialcounter-php-class-social-statistics/282826I found this guys – it worked a charm for me and was super easy.
Guess all I need to do is work on the styling – thats the fun part 
