How to Realize a Daily Activities Widget in WordPress Sidebar using SimplePie
- 11 June 2009
- Tutorials, WordPress
- This post was written exclusively for PV.M Garage by Piervincenzo Madeo
- Comments (20)»
It’s the moment of Social Networking and Social Bookmarking. Twitter, Delicious, Digg, Facebok… yes, maybe I’m doped! Yes, I believe in the power of the Social Connection. So I decided to show my social on-line life on PV.M Garage. How?
See in the bottom of my sidebar and you’ll understand. I’m convinced that sharing my updates on social web-site the reader could know more about me and my thinking and for this he could be encouraged for returning on my blog.

In this post I explain how I’ve realized the Daily Activities Widget with the stream of my updates on Twitter, Facebook, Digg and Delicious. The following information are valid only using WordPress.
To reach our purpose we use Simple Pie.
What is Simple Pie? It is a code library, written in PHP, intended to make it easy for people to manage RSS and Atom feeds. Imagine? It’s so!
I suggest to you a backup of the theme folder in WordPress because we’ll modify sidebar.php, style.css and we’ll add the folder for Simple Pie Cache and the Library itself.
How to use Simple Pie
First download the Simple Pie Library, after unzip the package and copy simplepie.inc in theme folder in your WordPress installation (presumably /wp-content/themes/yourtheme). Create a new folder called cache, this useful for caching system of our PHP Library that optimize the loading process of our web-page (learn more here “How does SimplePie’s caching system work?”).

Now add the following code in the top of sidebar.php to “activate” the RSS reader.
<?php
//get the simplepie library
require_once('simplepie.inc');
//grab the feeds
$feed = new SimplePie();
//our list of RSS
$feed->set_feed_url(array(
'http://feeds2.feedburner.com/pvmgarage',
'http://twitter.com/statuses/user_timeline/32445507.rss',
'http://feeds.delicious.com/v2/rss/piervix',
'http://digg.com/users/piervix/history.rss',
'http://www.facebook.com/feeds/share_posts.php?id=1658021339&viewer=1658021339&key=41c698e7f8&format=rss20',
));
//enable caching
$feed->enable_cache(true);
//complete path for caching system
$feed->set_cache_location('/web/htdocs/www.pvmgarage.com/home/en/pvmenglishcontent4984/themes/pvmgarage/cache');
//set the amount of seconds you want to cache the feed
$feed->set_cache_duration(1500);
//init the process
$feed->init();
//let simplepie handle the content type (atom, RSS...)
$feed->handle_content_type();
?>
Watching code
See the previous code and observe the array of RSS url. You can find them in your settings.
Activate with true boolean the cache and put the complete path of your cache folder in $feed->set_cache_location.
Remember that the folder for caching must be writable (chmod 777), read more on Change the file permissions to be server-writable?
Insert Widget on Sidebar
Now insert the following code to add a widget in the sidebar.php of WordPress.
<div class="sidecontdaily">
<!--<h2>My daily Activities</h2>-->
<ul class="daily">
<?php foreach ($feed->get_items(0, 5) as $item): ?><!--show 5 entries-->
<li>
<div class="info">
<p><span class="date"><?php echo $item->get_date('j M Y'); ?> | <?php echo $item->get_date('g:i a'); ?></span></p><!--date and time-->
</div>
<img src="<?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?>" class="icon" alt="" /><!--icon of social web-site-->
<h5 class="dailycont"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h5><!--title-->
<p><span class="linkfeed"><a href="<?php $feed = $item->get_feed(); echo $feed->get_permalink(); ?>"><?php $feed = $item->get_feed(); echo $feed->get_title(); ?></a></span></p><!--social web site-->
</li>
<?php endforeach; ?>
</ul>
</div>
Watching code
In this example we’re simply going to display five recent headlines, for this reason we insert <?php foreach ($feed->get_items(0, 5) as $item): ?>. Below you can see methods.
- <?php echo $item->get_date(‘j M Y’); ?> returns the date;
- <?php echo $item->get_date(‘g:i a’); ?> returns hour;
- <?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?> returns social web site favicon;
- <?php echo $item->get_permalink(); ?> returns entry url;
- <?php echo $item->get_title(); ?> returns entry title;
- <?php $feed = $item->get_feed(); echo $feed->get_permalink(); ?> returns your profile url;
- <?php $feed = $item->get_feed(); echo $feed->get_title(); ?> returns your profile name;
Style it!
Now modify the style.css. In my theme I’ve added the following code:
/*Simple Pie Style*/
.sidecontdaily {
margin: 0 0 15px 40px;
width: 278px;
background: url(immagini/dailyact1.png) no-repeat top;
}
ul.daily {
list-style: none;
padding: 90px 10px 50px 25px;
background: url(immagini/dailyact2.png) no-repeat bottom;
}
ul.daily li {
padding-bottom: 35px;
}
h5.dailycont {
font-size: 12px;
}
h5.dailycont a {
color: #69695f;
}
h5.dailycont a:hover {
color: #d54e21;
}
.info {
padding: 10px 0;
}
span.date {
background-color: #69695f;
color: #eee;
padding: 1px 3px;
font-size: 10px;
font-weight: bold;
}
img.icon {
float: left;
padding: 3px;
}
span.linkfeed {
background-color: #69695f;
float: right;
padding: 1px 3px;
margin-top: 3px;
}
span.linkfeed a {
color: #eee;
font-size: 10px;
font-weight: bold;
}
Conclusion and Source Files
With this hack we add a little box where we show our daily on-line activities, you can learn more about the use of Simple Pie in these articles: Easy feed reading with SimplePie; How to Create a Lifestream of Your Online Activities; Adding RSS Content with SimplePie.




25 Great Stock Images Plus with $100 Subscription Giveaway
Entrepreneurs that inspire you to grow your internet business

Great article. Added to Resource.
Great?! It’s amazing! Good for many uses.
Nice article. A quick note: If you’re using the latest version of WordPress, you don’t need to add SimplePie because it’s aldready there in wp-includes.
Thanks guys for positive comment…
@scribu: yes, I’ve read. Thanks for reporting, it’s correct and punctual.
In the last version of WordPress (2.8) there is the simple pie class in wp-includes folder (wp-includes/class-simplepie.php), so we don
Great… it’s so useful! It’s work… amazing trick without plugin!
There is fetch_feed($feed_url) function defined in WordPress that uses SimplePie and its caching sublibrary.
You effectively rewrote this function :)
Check the date, dear. This tutorial works with WP 2.7-
The function fetch_feed($feed_url) works for 2.8+
Thanks for the comment.
На портале всофте.ру всегда можно скачать скачать программы с “лекарствами” (crack, patch, etc), а также музыку, скрипты, фильмы, кники м ногое другое.
Также, советуем посетить наш компьютерный форум.
cfosspeed v510 build 1619 final crack keyrusskaya
flash slideshow maker крек
лекарство windows 7 ultimate idimm x32
ipod converter crack
ключ к фото шоу 2.51
скачать pfconfig
drweb security space pro 600004080 x8664 crack
cad конвектор
crack для adobe photoshop cs5
кряк uninstall tool
скачать русификатор для tipard blu-ray converter
скачать ключи 4 0 314 0
winzip pro 145 build 9095 final crack keygen
daemon tools pro advanced 4.36 ключ
скачать audio comparer 1
скачать русификатор gold wave pro
Hello.
to put video from mini dv cam i use pinnacle studio. the files must be mpeg2 to mpeg4 to be put on a VCD of SVCD or dvd
ipad video converter for mac
I want to voice my love for your kindness for folks who need guidance on this study. Your special commitment to getting the message all through had become quite functional and has regularly enabled folks much like me to arrive at their pursuits. Your helpful hints and tips signifies a great deal to me and still more to my office colleagues. Regards; from each one of us.
Whats up,
find out Online Bingo this fantastic bingo having really good bonus as well as promotion sign up at the moment to produce a real income .
Top Bingo Sites
Hello.
@ f_mageeSince you are very familiar with PgcEdit would you mind telling me how to change where my directory will be created when I open a DVD.Right now I get the message: "can’t create directory "F:/VIDEO_TS_backup": permission deniedI don’t want my backup to go to drive F: because that is my DVD drive. I want my backup directory to go to drive D: or G:Maybe I am doing something wrong but I can’t seem to get it to change. I have never used it before. Should I shrink first? I am not sure and was hoping you had the answer.Thanks a bundle in advance.
mac dvd to apple tv converter
jNyhVE http://fhYj30Mxb55m1SpveOxt.com
wow!I think you are amazing
hey there and thank you for your info – I’ve certainly picked up anything new from right here. I did however expertise several technical points using this site, as I experienced to reload the website lots of times previous to I could get it to load properly. I had been wondering if your hosting is OK? Not that I am complaining, but slow loading instances times will often affect your placement in google and could damage your high-quality score if ads and marketing with Adwords. Well I am adding this RSS to my e-mail and could look out for a lot more of your respective fascinating content. Ensure that you update this again very soon..
раздел http://adventure-travel.com.ua/wp-content/themes/adventure-travel-amazinggrace/images/bg-portrait3.jpg На информационном сайте о туризме Вы найдете интересные истории об водном отдыхе, окунетесь в мир экстремального туризма. Сайт для людей, которые любят путешествовать
пряжи http://adventure-travel.com.ua/wp-content/themes/adventure-travel-amazinggrace/images/bg-portrait3.jpg На информационном сайте о туризме Вы найдете интересные истории об активном отдыхе, окунетесь в мир экстремального отдыха. Сайт для людей, которые любят путешествовать
Some genuinely interesting details you have written. Aided me a lot, just what I was searching for : D. unmetered vps | cheap vps |