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:
<?php
// 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 = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace("<", "<", $tweet);
$tweet = str_replace(">", ">", $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
Leave a Reply Cancel reply
Blog Tycoon is a WordPress themes and plugins community, PHP/MySQL tutorials, industry news and personal thoughts on current web trends.
Stay updated
If you want to know about future events, updates and releases, leave your email address below to receive our newsletter.
Recent posts
-
The Future of Social Gaming, Courtesy of Microsoft
March 18th, 2011
Read more and discuss (0) » -
Quickstory Report: The Success of Foursquare
March 18th, 2011
Read more and discuss (0) » -
Life Elevated: Work at Adobe
March 17th, 2011
Read more and discuss (0) » -
How to Add a RSS Feed to a Static Site
February 20th, 2011
Read more and discuss (0) » -
PHP Multilanguage Site Using Arrays
February 17th, 2011
Read more and discuss (0) » -
Quick Tip: PHP Number Padding
February 17th, 2011
Read more and discuss (0) » -
Smart Backup Plugin
February 4th, 2011
Read more and discuss (0) » -
Beautiful Collection: Links of the Week
January 29th, 2011
Read more and discuss (0) » -
News, Upcoming Projects, 2011, Blogging and Journalism
January 29th, 2011
Read more and discuss (0) » -
Comics. Get it?
January 26th, 2011
Read more and discuss (0) »
Recent Comments
- Chip (278 comments) on PHP Random Images With Links
- Thiyagarajan Veluchamy (1 comments) on PHP Random Images With Links
- Chip (278 comments) on New WordPress Plugins Released!
- Pastor Bobby (1 comments) on I'm On Twitter!
- Chip (278 comments) on New WordPress Plugins Released!
- Chip (278 comments) on New WordPress Plugins Released!
- tim duncan (2 comments) on New WordPress Plugins Released!
- tim duncan (2 comments) on New WordPress Plugins Released!
- Chip (278 comments) on Blog Directories
- sam.j (1 comments) on Blog Directories
Latest on the forums!
-
Re: Couldnt find where to post about portable phpMyAdmin
by: Chip
March 12, 2011, 17:02 -
Re: How To Remove a Line?
by: Chip
February 14, 2011, 08:46 -
Re: Not working!
by: Chip
February 4, 2011, 20:11 -
Re: PayPal IPN not reporting successful payment
by: Chip
February 3, 2011, 13:43 -
Re: Euros instead of currency selected
by: Chip
February 3, 2011, 13:42
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.