Jim Westergren
About me, my projects, SEO, Web Development and Personal Development since 2005
"If we did all the things we are capable of, we would literally astound ourselves." - Thomas A. Edison

Display Links to Latest Items of a RSS Feed

With a simple RSS parser you can very easily make a list to latest items of a RSS feed, server side with PHP.

The uses of this is great, especially if you manage several web sites. It is great for users to see directly new fresh links and it is great for SEO and ranking in Google to get links to your blog posts and other things created directly for fast indexing and ranking.

Example of RSS feeds

On a Wordpress blog there are not only an RSS feed of the blog as a whole but to every category and comments on all posts as well (feed URLs for Wordpress). This means that if you have a category about marketing and you have another web site about marketing you could display links on that site to your latest articles about marketing. Other web sites that have feeds: All blogs, newspapers, Delicious (including a unique feed for each of your tag), Twitter, Flickr, forums (vBulletin have a unique feed for each section of the forum as well), digg.com, link directories (phpLD has a feed for each category as well) and a whole lot more. See some live examples here.

The RSS Parser

A good but simple RSS parser (just 1 PHP file) which have caching and handles non-english characters is called LastRSS and was made by Vojtech Semecky.

I have revised it a bit to make it more simple and I also included the correction by Cory S.N. LaViska so that fopen() does not make a problem.

Installation

  1. Download the file.
  2. Make a new directory called cache and CHMOD it to 777.
  3. Edit the top of the file to change the URL of the feed and how many items to show.
  4. Optionally: change other settings at the near bottom of the file.
  5. Then simply add this at the place you want to list to appear: <?php include("lastRSS.php"); ?>

This will only display the titles with links. If you want to show other things such as description you would need to change the code at near the bottom of the file.

If you want to show several different feeds on the same page you would need to have different files for each. You also need to edit the class name of LastRSS in the new files to for example lastRSS2, LastRSS3 and so forth. This is in line number 42 and 235.

See the official site of Last RSS for the original version and documentation.


Another more old version and can be downloaded here and I wrote about that in november 2005 here.

21 Jan 2009

About the Author Jim Westergren Jim Westergren is a Swedish web entrepreneur currently living in Spain. He is happily married and has three lovely children. Some of his interests are web development, SEO and writing.
He is the Founder of DomainStats and N.nu. Read his .