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"); ?>
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