Display Twitter Follower Count as Text

Posted by ADMIN On 4:38 AM
There are users who absolutely hate buttons like Feedburner buttons or Twittercounter buttons. Are you one of them? Do you want to display your twitter count as text, so it blends in to your new custom design? Well then this hack is just for you.

First you would need to create a file twitter.php and paste the following code in there:

    <?php
    $tw = get_option("twitterfollowerscount");
    if ($tw['lastcheck'] < ( mktime() – 3600 ) )
    {
    $xml=file_get_contents('http://twitter.com/users/show.xml?screen_name=wpbeginner');
    if (preg_match('/followers_count>(.*)</',$xml,$match)!=0) {

    $tw['count'] = $match[1];
    }
    $tw['lastcheck'] = mktime();
    update_option("twitterfollowerscount",$tw);
    }
    echo $tw['count'];
    ?>

Make sure to replace wpbeginner with your twitter name.

Then Simply place this code anywhere you want to display this:

    <?php include("twitter.php"); ?>

0 Response to "Display Twitter Follower Count as Text"

Post a Comment

Google Translator

Search Box

Blog Archive

User Status

Free counters!

About Me

ADMIN
Pakistan
View my complete profile

Recent Posts

Recent Comments