Display latest tweets on WordPress without a plugin

Do you want to display your latest tweets on your blog? There are many plugins for that, but sometimes you need to code it your self without adding a plugin. So here is how to do it.

You can view the [Live Demo]

paste the following code anywhere in your theme

don’t forget to add your twitter username on line 4 (change flashsolver to your name)

Last update 05th June 2012

  • Faizalqurni

    it doesn’t work

  • LincolnLemos

    Dont working again…

    • I’ve tested it and its working fine, how are you installing it?

      • LincolnLemos

        i just copy the code and paste on my function (add_dashboard_widgets).
        I try paste on my loop to, but none works.

        • Did you add your twitter username? it picks up recent tweets so you need to have a tweet within the same day you test it

          here is how i added my code in the sidebar.php file


          Twitter thing <?php # Your twitter username. $username = "incoe"; # Prefix or header. $prefix = "My last Tweet"; $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1"; function parse_feed($feed) { $stepOne = explode("", $feed); $stepTwo = explode("", $stepOne[1]); $tweet = $stepTwo[0]; $tweet = str_replace("<", "", $tweet); return $tweet; } $twitterFeed = file_get_contents($feed); echo stripslashes($prefix) . parse_feed($twitterFeed); ?>

          let me know if it works for you

          • LincolnLemos

            I try using my and your user, but none works.
            Can you send me this paste of code in pastebin?

            He became unreadable here in comments.

          • @LincolnLemos:disqus it’s the same code as above, what sort of error does it show on your website? your server needs to have allow_url_fopen on for this to work by the way