In this short article I am going to show you how to create a rss feed; I know there are a lot of web applications that could do the job for you out there (Feedburner for example or the built-in rss feed in WordPress) but it is always useful to understand how a rss works.
The feed is in xml format and must be linked in the <head> tag of your page:
I use this simple structure for my rss
<rss version="2.0">
<channel>
<title>your title (claudiocugia.com)</title>
<link>http://www.claudiocugia.com</link>
<description>Feed created by</description>
<language>IT-it</language>
<item>
<title>13 Febbraio 2009 | my feed title</title>
<description>13 Febbraio 2009 | my feed title</description>
<link>link to your page </link>
</item>
</channel>
</rss>
So, for every news I use the ‘item tag’ with the title, the description and, of course, the link to the page.
Usually I have many news on my websites and it would be hard to write an ‘item’ for each; so I use php to retrieve all the news via a query string and serve the page as an xml file. To do this I just create a php file with this header:
header("Content-Type: application/xml; charset=iso-8859-1");
query_feed();
I hope this helps.



Pingback: A rss feed for your website | PHP-Blog.com