How To Display Twitter Follower Count as Plain Text? Some people do not want to display any fancy buttons to display Twitter Followers count or similar social network details. If you just want to display the twitter followers count as text then this post could help you.
Also if you display the Twitter count as Text you can save space inventory as well as download time. The more images you have in your web page the more time it will take to load.
In other words using just simple text instead of images can help you to achieve performance improvement also.
Related:
Write your own Twitter widget in (Recent Tweets) 3 steps using twitter API.
How to Display FeedBurner RSS Feed Subscriber Count As Text
Globinch Feedburner RSS Feed Statistics Tool
Display Twitter Followers Count AS Text
How to display Twitter Follower Count as Text? There are different ways of achieving this. Either you need to create a Page and use the page to display the Twitter count or you need to embed the PHP code in post or page or widget. Usually wordpress won’t allow you to include PHP code in pots, page or sidebar. Read how to Insert, Execute, Embed or Include PHP Code in WordPress Post, Page or Sidebar.
First you would need to create a php file (“twitercount.php”) and add the below given code in that file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php $twitterid = "globinch"; $stringVal=""; $url="http://twitter.com/users/show.xml?screen_name="; $url= $url. $twitterid; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); $xml = new SimpleXMLElement($data); $followers = $xml->followers_count; echo "<div style='color:red;font-size: 14px;font-weight: bold;line-height: 15px;'>" . $followers ." : Twitter Followers Today" . "</div>"; // The above $followers value can be displayed any where in the page below the above code using echo. Eg.:echo $followers ; ?> |
Replace “globinch” with what ever twiter username you want to use. Save it and uplload to your wordpress theme folder. Now you can embed this in any palce where you want to display the Twitter followers count as shown below.
But remember if you want to display this directly inside post of page by including the code you need to use plugins to insert PHP code in post, page or widget. Otherwise you need to manually edit the respective page and include the above code.
Before you go, subscribe to get latest technology articles right in your mailbox!.
Works great thanks!