Display The Number Of Your Twitter Followers in WordPress

So you have bazillions of followers on Twitter and you want to display your Twitter dominance to all the people who visit your blog huh? If you are not a fan of plugins you can display your follow count in plain text and style it to your liking later on.

2-Week 30-40% OFF Promo

Paste the following php code in the functions.php file from your WordPress blog theme…

function string_getInsertedString($long_string,$short_string,$is_html=false){
if($short_string>=strlen($long_string))return false;
if($is_html && $inserted_string[$insertion_length-1]==’<’){
return $inserted_string;

function DOMElement_getOuterHTML($document,$element){
return string_getInsertedString($html,$html2,true);

function getFollowers($username){
$x = file_get_contents("http://twitter.com/".$username);
$doc = new DomDocument;
$ele = $doc->getElementById(‘follower_count’);
return $innerHTML;

Once you have done this you simply paste the following anywhere on your theme files. Just replace “wpswitch” with your Twitter username.

[php]<?php echo getFollowers("wpswitch")." followers"; ?>[/php]

.via { WpRecipes }

19,612 Website Templates and Themes From $3