(+84) 463.28.7979

Displaying the Total Number of Twitter Followers as Text on WordPress

Yes it is great that you can have a twitter follower button from many sites. But what if you are trying to make a very custom design where you want to place a code in text instead of using a button. Well then this tutorial is for you. In this tutorial we will show you how you can display the total number of twitter followers as text on your WordPress site.

Create a new file called twitter.php file located in your themes folder. Remember to make sure that you change WPBeginner to your username.

$tw = get_option(“twitterfollowerscount”);
if ($tw['lastcheck'] < ( mktime() – 3600 ) )
if (preg_match(‘/followers_count>(.*)</’,$xml,$match)!=0) {
$tw['count'] = $match[1];
$tw['lastcheck'] = mktime();
echo $tw['count'];

Then simply paste this code any where you want in your theme files.

<?php include(“twitter.php”); ?>

Now you can display the number of twitter followers on your WordPress site as text.

Source: Rarst

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>