Solved

Last 3 tweets in WordPress

Posted on 2010-08-25
4
571 Views
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){

     include_once(ABSPATH.WPINC.'/rss.php');

     $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?

Thanks
0
Comment
Question by:vertigogroup
  • 2
4 Comments
 
LVL 4

Expert Comment

by:javaftper
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");

0
 

Author Comment

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

Accepted Solution

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

http://jhnk.pastebin.com/5A4aXYTW
0
 

Author Closing Comment

by:vertigogroup
ID: 33524089
Works like a charm. Thanks!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 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