Jim Westergren
A blog about me, my projects, SEO, Web Development and Personal Development.
"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.


  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.

Boomark This! Subscribe to the RSS feed
About the Author Jim Westergren Jim Westergren is a web entrepreneur from Sweden now living in Bolivia. He is happily married and has two lovely children. Some of his interests are web development, SEO and writing. He is the Founder and CTO of TodaysWeb and his current major project is N.nu. Read his . Follow Jim on Twitter or Google+.
  • http://apalm.se Anders Palm

    Hej Jim,

    verkar vara ett bra skript, men av n[gon anledning fick jag det inte att fungera. Jag försökte lägga till det nere till höger på anderspalm.com men fick bara meddelandet “Not working”. Jag följde dina instruktioner och har kollat så att flödet fungerar. Något tips?

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    Hej Anders,

    Gäller det ett svenskt flöde från WordPress? Jag gissar då att det beror på någon slags krock mellan UTF-8 och iso-8859-1 men jag kan givetvis ha fel. Svenska flödet från mitt forum fungerade men inte från WordPress. Jag ska titta närmare på det nästa vecka. Om du hittar en lösning tills dess så meddela gärna här så kommer jag revidera min artikel med länk.
    Jag provade detta men det verkade inte fungera – tror problemet ligger hos WordPress.

  • http://apalm.se Anders Palm

    Nej, jag testade med ett par olika flöden, på svenska, engelska och vietnamesiska. Fick det tyvärr inte att fungera, synd då jag funderat på hur man löser det där tidigare.

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    Tror det måste bero på din webbhost och serverinställningarna. Kanske safe_mode. Kommer att återkomma här när jag vet svaret, om du har möjlighet så prova på en annan server.

  • http://bewithcijo.blogspot.com/2009/03/sulumits-retsambew.html Sulumits Retsambew

    RSS feed submission and RSS feed subscription is getting a lot of priority and it is a nice way to earn a lot of readers. I will make an RSS feed for all the blogs I write.

  • http://newreil.com kampanye damai pemilu indonesia 2009

    hi jim, where i must put the php file

  • http://www.visbysilvergold.com G?ran Andersson

    Hi Jim

    - First day with RSS Feeds –
    …and maybe Off-topic …..

    How will the script effect backlinks? I got the following explanation after I had a discussion about “reciprocal links” with a webmaster in Germany. Notice the “?”.

    “Some months ago Google dramatically changed its system of pagerank and for example doesn’t seem to give any pagerank to urls containing a question mark any more (e.g.: http://www.domain.com/link.html?category=LinkPartners). Since many link partner urls are built this way (ours is not), it is much more difficult then before to gain pagerank using link exchange. Our domains therefore dropped from a 4 at the starting page to a 3. And that is the whole problem with at least our link directory. Since pagerank usually drops by 1 per page and our link partner pages are three clicks away from our starting page they are a 0 at the moment.”

    I?ve reduced the links on my site (after the explanation). If your sites are built with scripts, Google will certainly elimiate all your work(?).

    Best regards
    G?ran Andersson

  • http://www.visbysilvergold.com Goran Andersson

    Hi Jim

    I forgot to mention: What I meant was, if there are unwanted sites at my link pages because of the above problem with “question marks”, but these sites are represented in the feeds list. Will my sites give the the other sites higher PR through your script when they give nothing in return?

    Regards, Goran
    Visby Silvergrotta

  • http://www.jimwestergren.com/about-me-jim-westergren/ Jim Westergren

    Hi G?ran,

    This webmaster in Germany does not really know what he is talking about.

    Google has no problem with URL’s containing a question mark – at least not the last 8 years or so.

    Furthermore I believe that most of the web pages on the internet are built with a script such as this blog.

    I am sorry but it is difficult to understand your question in your second comment.

    Anyway, good luck. And I think it would be better reading straight from Googles help pages instead of listening to this webmaster.

  • Magnus

    Jag kör svenskt WordPress och hade också problem med åäö men satte bara charset till UTF-8 så fungerade det felfritt. Är inte säker på att det var det problemet som beskrevs ovan, men om det var det så är det lösningen =), fast det är klart, då måste man ju fixa alla åäö i koden också, så det medför ju lite jobb om man inte gjort det från början.
    I övrigt, tack för guiden!

  • http://triindi.com Tri

    Hi Jim,
    How to add Last RSS to PHP Scripts?
    I use Directory Site, Phplinkdirectory (v4.1) and want to add Latest OR one last RSS to their detail page on Our diretory.

    I’m Newbie :)

    Thanks in advance

  • http://www.petterhedman.com Petter Hedman

    Vilken bra guide Jim!

    tack för all hjälp!

    Petter Hedman

  • Pingback: Hur få besökare till bloggen? Hur göra för att få trafik till bloggen?

  • http://ottsjo.blogspot.com Tina Ponting

    TACK! väldans bra och enkelt för mig att göra!

Previous post in category:

Next post in category:

Design, text and custom cache solution by myself.

Page generated in
0.00397 sec