Breaking News
Loading...

Display Total Number of Twitter Followers in Blogger and WordPress Blogs

11:33 AM
Twitter has gained so much popularity and almost every one is aware of this micro blogging service. Almost all bloggers and webmasters have joined twitter and if you are one of them, then probably you had once wished to display total number of followers in either your WordPress blog or in your Blogspot blog. Well, whatever your blogging platform is, its really very easy to display your total number of twitter followers in text mood or in chicklet. You can also show number of feedburner subscribers in WordPress or in Blogger.

Display Twitter Followers on Your WordPress blog in Full Text Mood

By showing twitter followers in text mood, you can style your twitter followers count using style sheets. Here is how you can show twitter followers in WordPress.

  • Login in Your WordPress admin panel.
  • Go to Theme Editor and open functions.php file.
  • Paste this code in to this file
function string_getInsertedString($long_string,$short_string,$is_html=false){
if($short_string>=strlen($long_string))return false;
$insertion_length=strlen($long_string)-strlen($short_string);
for($i=0;$isaveHTML();
$element->parentNode->removeChild($element);
$html2=$document->saveHTML();
return string_getInsertedString($html,$html2,true);
}

function getFollowers($username){
$x = file_get_contents("http://twitter.com/".$username);
$doc = new DomDocument;
@$doc->loadHTML($x);
$ele = $doc->getElementById('follower_count');
$innerHTML=preg_replace('/^< [^>]*>(.*)< [^>]*>$/',"\\1",DOMElement_getOuterHTML($doc,$ele));
return $innerHTML;
}
  • Save that File.
  • Now, paste this code anywhere in your theme files i.e. where you want to display number of followers in text mood.
<?php echo getFollowers("catswhocode")." followers"; ?>
  •  Thats it -- moreover you can also use style sheet for lovely style

Display Twitter Followers on Your Blogspot blog

TwitterCounter.com is a free service which gives you free chicklet that shows number of twitter followers. The chicklet looks similar to Feedburner's official chicklet.

  • Go to TwitterCounter.com
  • Enter Your Twitter username in box shown in front and click on "show me"


  • Now, a Pop-op will appear asking your twitter username and password. Its time to authorize this website accessing your twitter account.
  • Once you have entered your username and password, this website will take you back to TwitterCounter.com page.
  • Click on "Buttons" and you will see number of chicklets displaying your number of followers in different styles.



  • Copy the code and paste into your blogger HTML/Java Script widget.
  • Thats it

Moreover, you can use this code in your WordPress blog also however you can not show number of followers in plain text on your blogspot blogs.
       
      Toggle Footer