OUseful.Info, the blog…

Trying to find useful things to do with emerging technologies in open education

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:

http://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=”http://ouseful.wordpress.com/2009/07/07/mash-oop-north-pipes-mashup-by-way-of-an-apology/”&gt;

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:

<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 (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:

Okay, Brian?:-)

Written by Tony Hirst

July 8, 2009 at 4:46 pm

Posted in Tinkering

Tagged with , , ,

13 Responses

Subscribe to comments with RSS.

  1. TOny,

    Nice work, and a brilliant tutorial, thank you!

    Jim

    July 8, 2009 at 4:52 pm

  2. Just enough explanation to be useful to lots of people, and not so much that the eyes glaze over. Excellently done!

    Kevin Ashley

    July 8, 2009 at 7:35 pm

  3. 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.

    Brian

    July 8, 2009 at 7:54 pm

  4. [...] , Tinkering Leave a Comment Tags: RSS, single item RSS, WordPress, WP Having posted about Single Item RSS Feeds on WordPress blogs: RSS For the Content of This Page, it struck me that whilst this facility might be of interest to a very, very select few, most [...]

  5. 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?

    Tony Karrer

    July 13, 2009 at 1:48 pm

  6. @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.

    Tony Hirst

    July 13, 2009 at 3:35 pm

  7. 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.

    Tony Karrer

    July 13, 2009 at 4:02 pm

  8. “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…:-(

    Tony Hirst

    July 13, 2009 at 5:19 pm

  9. 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.

    Kyle

    August 12, 2009 at 8:31 am

  10. 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.

    Marcus Jordan

    October 30, 2009 at 7:07 pm

  11. [...] the page can be made available as a separate item in an RSS feed; that is, as well as the standard ’single item’ RSS page feed that WordPress generates automatically, we can get an N-item feed from the page for the [...]

  12. [...] the page can be made available as a separate item in an RSS feed; that is, as well as the standard ’single item’ RSS page feed that WordPress generates automatically, we can get an N-item feed from the page for the [...]

  13. [...] answer to this question was provided by Tony Hirst in a post on Single Item RSS Feeds on WordPress blogs: RSS For the Content of This Page which he wrote in July 2009. Unlike many of Tony’s development activities which Tony [...]


Comments are closed.

Follow

Get every new post delivered to your Inbox.

Join 813 other followers

%d bloggers like this: