Google it! / Yahoo it! / Bing it! / Ask it!

I’ve always wanted to show my last twits in my sidebar. I’ve recently found out how. Here’s a quick tutorial:

Place the following code in your sidebar. Remember to style it properly and replace the username:

// Your twitter username.
$username = "butterflymedia";
// Prefix - some text you want displayed before your latest tweet.
$prefix = "<h3>My last Tweet</h3>";
// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = "";
$feed = "" . $username . "&rpp=1";
function parse_feed($feed) {
    $stepOne = explode("<content type=\"html\">", $feed);
    $stepTwo = explode("</content>", $stepOne[1]);
    $tweet = $stepTwo[0];
    $tweet = str_replace("&lt;", "<", $tweet);
    $tweet = str_replace("&gt;", ">", $tweet);
    return $tweet;
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);

6 Responses to How To Add Latest Twits To Your Sidebar

  • thank you for a code I searched him long

  • nice post, that is a really easy way to do what i want. viva la twitter!

  • Fantastic post! this post have more informative code which more useful for me so thanks for given this.

  • It sure does help when information gets shared by folks like you. Especially for non-coders like me! I still don’t really use twitter, but am starting to sit up and take notice, because the hype has to have some form of substance behind it, especially when it gets touted as the next Google!

  • thanks for this post i knew about it already but it will be so helpful for new blogger.

  • I’m glad you all find this information helpful. I’ll try to post more tutorials in the future.


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>