fbpx
Show Twitter Followers Count in WordPress

Show Twitter Followers Count in WordPress

This WordPress snippet grabs and displays the number of Twitter followers the specified user has.

Instructions
Add this to your template file where you want it to be displayed.
*Change USERNAME to the Twitter Username you want to get the stats from.

<?php
     $twit = file_get_contents('http://twitter.com/users/show/USERNAME.xml');
     $begin = '<followers_count>'; $end = '</followers_count>';
     $page = $twit;
     $parts = explode($begin,$page);
     $page = $parts[1];
     $parts = explode($end,$page);
     $tcount = $parts[0];
     
     if($tcount == '') { $tcount = '0'; }
    echo '<b> '.$tcount.' </b> followers.';
?>