How To Display Twitter counter in Text


Sponsored Links




Update: Better Code Display Twitter Counter Text using WordPress Api

Display Twitter Counter in Text is easily in WordPress with PHP code, all need to do just write down some PHP Script in our wordpress theme, we can write it on sidebar.php, footer.php, header.php or whatever we want to put on.

This code is similar with our previous tutorial about display FeedBurner counter in text, but we need to change some code, because the source is different, we still use file_get_contents() functions, this functions is the some function that we use to modified TimThumb Script to make it work on some server problem. So, let’s get started

Write down Display Twitter Counter in Text code below

<?php
$twit = file_get_contents('http://twitter.com/users/show/USERNAME.xml');
$begin = '<followers_count>'; $end = '</followers_count>';
$page = $twit;
$parts = explode($begin,$page);
$page = $parts[1];
$parts = explode($end,$page);
$tcount = $parts[0];
if($tcount == '') { $tcount = '0'; }
echo '<div class="twitter-badge"><strong>'.$tcount.' </strong> Followers</div>';

?>

Replace USERNAME with your own USERNAME, example our Twitter username is @WPTricksNet (you can follow it if you want ;)

That’s all, save your code and test it… I hope tutorial display Twitter Counter in Text work like charms just like our FeedBurner Counter in Text tricks too. Thanks for Webm.ag for share, via ThemeGamag Don’t forget to subscribe our RSS

Update: Better Code Display Twitter Counter Text using WordPress Api

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net


26 Responses to How To Display Twitter counter in Text

  1. Pingback: Mostrar el Numero de seguidores de Twitter en Wordpress | Recursos para Diseñadores Gráficos y Web | Creativos Online

  2. Tech Tricks says:

    I was searching google and other search engine and I found this solutions on this site… this is super tutorial..

    thanks for share

  3. Wonderful Twitter Tricks, I was try to find out this code for a while.. and we got it here

  4. Freelancer Witrer says:

    When will google buzz overtake twitter?

    • WP Tricks says:

      I think it’s will never happen.. Google Buzz it’s look like similar with Twitter… but it’s different…. Buzz is more thatn 140 Character… it’s Feed syndication from many many services included Twitter… ;)

  5. Pingback: The Ultimate Guide To Wordpress Hacks And Customizations | pro2go Designs Blog

  6. Pingback: Wordpress Hacks e Customizations! | sinergie.::.websolution | il blog

  7. TechGyo says:

    Great tip. Thanks for sharing

  8. Pingback: sinergie.::.websolution » Blog Archive » Wordpress Hacks e Customizations!

  9. Space Game says:

    Why not create a plugin for that? A lot of people are not familiar with php coding and how to run that code.

  10. Really nice tips.thanks for your help, man!
    Go on with it!

  11. Katie says:

    Thanks, this is the only twitter code I’ve gotten to work. :)

  12. poker says:

    Hey guys, there is a simpler option that prints out the Twitter follower counter as plain text for WordPress blogs.

    I’ve developed a plugin that does that with an extra: you know how if Twitter is offline (fail whale) or it is slow, and how it impacts on your site, making it slow too?
    I’ve figured out a way to solve that by simply creating a cache. If Twitter is down, you still get your followers shown as it grabs the last known number of followers.
    Pretty neat, huh? Just check out the WordPress Plugin Directory for “Twitter Counter Cache-rizer”. Easy to install and works just fine!
    Here’s the link if you’re interrested:
    http://wordpress.org/extend/plugins/twitter-counter-cache-rizer/

    Hope it helps someone out!

    By the way, awesome blog design! I loved this wooden theme!

  13. Pingback: Mostrar el numero de tus seguidores en Twitter | Blog de Miguel Chang

  14. Pingback: wp-popular.com » Blog Archive » How To Display Twitter counter in Text # WordPress Tricks & Tips

  15. Thank you this twitter counter works great on my site. I will recommend it to my blog partners..

    • vanessa says:

      hi, thank you for the code, really very helpful.

      anyway, how do we display the number of friends or twitter accounts followed on my site/blog?

      thank you, i truly appreciate it. ;)

  16. Cool tutorial. Will be cool to get a twitter counter on my blog.

  17. UIAvenue says:

    Really cool tutorial. I was searching for it. I am searching for a plugin to display both twitter counter and rss feed reader counter, though.

  18. Jefferson says:

    Great tip, it’ll help me. :)

  19. Pingback: The Better Way Display Twitter Followers in Text # WordPress Tricks & Tips

  20. Pingback: How To Autolink on Twitter Username | WordPress News Wire

  21. Pingback: Welcome to WPTricks.net | WordPress News Wire

  22. Pingback: How to Display Twitter Counter in Text | Fazreen

  23. Kpop Flash says:

    another great related post plugin is nRelate. I’m sure it will be great! thanks for the tutorial :)

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>