Last 3 tweets in WordPress

Posted on 2010-08-25
Medium Priority
Last Modified: 2012-05-10
I am current using the wp_echoTwitter code to show the last tweet on my blog. I am looking to show the last 3 tweets.

I have this in my functions.php file:
function wp_echoTwitter($username){


     $tweet = fetch_rss("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1");

     echo $tweet->items[0]['atom_content'];

Open in new window

And I have this added to my sidebar
		<h3><?php wp_echoTwitter('twitteruser'); ?></h3>
		<h2><a href="http://twitter.com/twitteruser">Follow twitteruser on Twitter</a></h2>

Open in new window

Any ideas?

Question by:vertigogroup
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 33522414
All you have to do is change the value of rrp to however many tweets you want to show, so-

$tweet = fetch_rss("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1");

should be changed to-

$tweet = fetch_rss("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=3");


Author Comment

ID: 33522530
I tried that but it still showed only 1. Do I need to wait an hour before it displays?

Accepted Solution

wuff earned 2000 total points
ID: 33523861
You are still accessing the first one. You need to loop them through. Check this update of the function:


Author Closing Comment

ID: 33524089
Works like a charm. Thanks!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question