Arguably, a website isn’t quite complete unless it offers an RSS feed. I haven’t had an RSS feed for a long time, with any of my websites. Yesterday, I decided to change all that. An RSS feed means you don’t have to visit my website to find out if I’ve published anything since the last time you visited. You can read my tripe as you see fit.
It took me a while to figure things out. The format looks like this:
<?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>website title</title> <description>website description</description> <link>https://website-link/</link> <atom:link href="https://website-link/feed.xml" rel="self" type="application/rss+xml" />
<item> <title>post title</title>
<link>https://post-link</link> <guid>https://post-link</guid> <pubDate>Sat, 10 Oct 2020 01:01:01 +0000</pubDate>
</item> </channel> </rss>
Most of it’s pretty simple. It’s the content (called “description” above) that’s the most difficult to get right. I did this:
$description = strip_tags($content, '<a><br><em><h2><iframe><img><li><ol><p><small><strong><ul>'); $description = '<![CDATA[' . trim($description) . ']]>';
That pretty much takes care of everything, while stripping out ads and such. The “item” section is just a loop though every post.
I decided to include the full post in the feed. Why force you to visit if you’re not going to comment on it? Just to get you to look at ads? I don’t make enough from ads to worry about it and I probably never will.
So far, I’ve only tested the feed with QuiteRSS. It’s what I use to view feeds from various websites anyway. I don’t want to install other feed readers just to prove it works. Anyway…
If you scroll to the boot of the page, you’ll see the link to “RSS Feed”. Copy the URL and paste into whatever feed reader you want to use and it should work properly. Enjoy!