Single Item RSS Feeds on WordPress blogs: RSS For the Content of This Page
At Mash Oop North yesterday, Brian Kelly askd me how I got the “RSS for the content of this page” link onto my (hosted) WordPress blog:
Clicking the link on an arbitrary blog post page turns up an RSS feed containing just a single item: the content of that blog post.
The trick is quite simple, and relies on a couple of things.
The first thing you need to know is that you can get a single item RSS feed containing an RSS version of a single WordPress blog page by adding ?feed=rss2&withoutcomments=1 to the end of the page URL.
So for example, the RSS version of the post that lives here:
on Brian’s blog can be found here:
The second thing you need to be aware of is how wb browsers handle links that appear in a web page, and in particular how they handle relative links. Relative links are most easily thought of as links in a web page that do not specify the domain of the link. So for example, on this blog, the domain is ouseful.wordpress.com. Links to posts on OUseful.info look something like the following:
An absolute way of writing this as a link in a web page would be to write the link in an HTML anchor tag as follows:
That is, we specify the domain (http://ouseful.wordpress.com) and the path to the resource as well as the resource page itself.
A relative link would be written as follows:
with the browser filling in the gaps using the domain that the page itself is served from (http://ouseful.wordpress.com).
(For a basic grounding in how browsers handle relative links, see Absolute vs. Relative Paths/Links. If you want the hardcore standards stuff, you should read the original RFC: RFC 1808: Relative Uniform Resource Locators.)
One further thing to know about relative links is that in you use something of the form ?foo=bar in the link (e.g. <a href=”?foo=bar”>), the browser will add the argument to the end of the current page’s URL. So if the page mypage.html being served from http://example.com contains the relative link <a href=”?foo=bar”> that link will actually point to http://example.com/mypage.html?foo=bar.
Putting these two things together (how to create a URI for the single item RSS feed version of a post, and how to construct relative URIs), we are now in a position to add an ‘RSS version of this page’ link to a WordPress blog sidebar.
So, to get the single item RSS feed link, go to the Widgets settings area of your WordPress blog and add a text widget as follows: