/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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(); ?>
Comments
