Revision: 52364
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 21, 2011 02:26 by florent
Initial Code
function get_follower_Count(){ $count = get_transient('follower_count'); if ($count !== false) return $count; $count = 0; $data = wp_remote_get('http://api.twitter.com/1/users/show.json?screen_name=YOURNAME'); if (!is_wp_error($data)) { $value = json_decode($data['body'],true); $count = $value['followers_count']; } set_transient('follower_count', $count, 60*60); // 1 hour cache return $count; } Add the first section of code to the functions.php of your wordpress theme. This code will cache your Twitter follower number for 1 hour and display the count within your template. <? get_follower_count(); ?>
Initial URL
Initial Description
Initial Title
Cached Twitter Follower Count
Initial Tags
wordpress, twitter
Initial Language
PHP