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:
http://ukwebfocus.wordpress.com/2009/07/06/enthusiastic-amateurs-and-overcoming-institutional-inertia/
on Brian’s blog can be found here:
http://ukwebfocus.wordpress.com/2009/07/06/enthusiastic-amateurs-and-overcoming-institutional-inertia/?feed=rss2&withoutcomments=1

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:

https://ouseful.wordpress.com/2009/07/07/mash-oop-north-pipes-mashup-by-way-of-an-apology/

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:

<a href=”https://ouseful.wordpress.com/2009/07/07/mash-oop-north-pipes-mashup-by-way-of-an-apology/”&gt;

That is, we specify the domain (https://ouseful.wordpress.com) and the path to the resource as well as the resource page itself.

A relative link would be written as follows:

<a href=”2009/07/07/mash-oop-north-pipes-mashup-by-way-of-an-apology/”>

with the browser filling in the gaps using the domain that the page itself is served from (https://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:

Okay, Brian?:-)

Author: Tony Hirst

I'm a Senior Lecturer at The Open University, with an interest in #opendata policy and practice, as well as general web tinkering...

13 thoughts on “Single Item RSS Feeds on WordPress blogs: RSS For the Content of This Page”

  1. Another Brian says “Okay, and many thanks!”

    This will hopefully tide me over until the next installment of “Getting to Grips with OUseful.info” comes out.

  2. Somehow I was not aware of that trick – RSS for a single page. That’s a really great thing – gives you clean content for a page.

    Is there something similar for Typepad and Blogger?

  3. @Tony asks “Is there something similar for Typepad and Blogger?”

    Not as far as I know; it’s possible to writ a screenscraper for a given template, but that’s not ideal and only really works for bespoke situations…

    In my experience, WordPress offers by far and away the best support for feeds/simple XML publishing in the blogging app arena.

  4. In fairness to Blogger, it does offer some additional parameters that let you go back and grab additional posts – I think it was as many as the last 500.

    Scraping is way too painful across lots of blogs. Just too many variations. The nice thing about RSS is that it’s very clean content. Just some ads in some.

  5. “In fairness to Blogger, it does offer some additional parameters that let you go back and grab additional posts – I think it was as many as the last 500. ”

    So if that applies to category feeds, or the blog has less than 500 items, you can probably finesse a single RSS item feed by grabbing the whole feed and then filtering on the title e.g. within a Yahoo pipe. That’s a recipe I’ve used before now!

    “Embedding Single OpenLearn Unit Pages in an Arbitrary Blog Post” [ http://ouseful.open.ac.uk/blogarchive/014352.html ]

    (The bookmarklet is here:
    “Single Item RSS Feeds from OpenLearn Pages” [ http://ouseful.open.ac.uk/blogarchive/014352.html ]
    )

    Re: scraping – agreed: I was just suggesting the workaround;-) ANd re: feeds – as well as ads, sometimes you’re limited by publishers only releasing partial, rather than full text, feeds…:-(

  6. Hi, thanks for the great tutorial. i have it working on my site but the RSS comes up without any styling, have I missed a step? the s tyling works fine for the built in wordpress blog RSS feed…

    thanks! site is here:

    http://www.thefifthestate.co.uk and the single page feed i’ve added is the “subscribe to news feed” link in the right sidebar.

  7. Thank you so much for this tutorial Tony…
    I was starting building my own plugin to do that when i found your solution. You saved me a lot of time, but i was just wondering, is it possible to use that with a custom feed template ?
    I see that i can do that with the Atom and RSS2, but for example the RDF doesn´t work.
    I have a function in my template to generate a custom feed to a flash slideshow which can be access with index.php?feed=sidebar or just sidebar.xml.
    Here is the example: http://testosterona.blog.br/sidebar.xml
    Do you have any idea how i could make wordpress generate the single item feed with my own template?
    Thanks in advanced.

Comments are closed.