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.

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.

Tweet this! Boomark This! Subscribe to the RSS feed
About the Author Jim Westergren Jim Westergren is a company owner from Sweden who lives together with his wife and son. Some of his interests are SEO, web development, writing and taking photos. Read his full about page or contact him. Follow Jim on Twitter or subscribe to this blog.
In Swedish: presentation, blog.
10 responses »Leave a comment
  1. Anders Palm
    said on January 22, 2009 at 6:37 am

    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?

  2. Jim Westergren
    said on January 22, 2009 at 7:11 pm

    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.

  3. Anders Palm
    said on January 25, 2009 at 7:17 am

    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.

  4. Jim Westergren
    said on January 26, 2009 at 8:14 pm

    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.

  5. Sulumits Retsambew
    said on March 24, 2009 at 7:49 am

    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.

  6. kampanye damai pemilu indonesia 2009
    said on April 17, 2009 at 5:14 pm

    hi jim, where i must put the php file
    thanks

  7. G?ran Andersson
    said on August 25, 2009 at 12:35 am

    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

  8. Goran Andersson
    said on August 25, 2009 at 11:38 pm

    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

  9. Jim Westergren
    said on September 18, 2009 at 4:21 pm

    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.

  10. Magnus
    said on December 22, 2009 at 6:35 pm

    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!

Leave a Comment

To quote: <blockquote>text to quote</blockquote>

You can use these tags: <a href=""> <blockquote> <code> <em> <strong>


To have a photo of you beside your comments, upload a photo here.

Previous post in category: Checklist when won a web site auction

Next post in category: Redesign of JimWestergren.com

Design by myself:  valid XHTML and valid CSS.