While working on TDO-Forum, I had to generate a RSS feed for new “forum posts”, not just posts but posts and comments. So I was digging into the RSS feed code. And I discovered something kind of neat.
I knew you get an RSS feed for posts with a specific tag in WordPress 2.3. I used it on the TDO Mini-Forms plugin as a news page. But did you know you can get an RSS feed for a search too? Neither the tag nor the search rss feed seem to be really support by template tags so you can’t really access them normally within a theme or from a WordPress enabled webpage.
BTW If you have a site using FeedBurner to wrap RSS feeds and you are using FeedBurner FeedSmith plugin, then this won’t work. This plugin will wrap your posts RSS feed and ignore tag and search distinctions. I did a bit of hacking in th version of this plugin I use on this site to make this post work.
To get an RSS feed for posts with a specific tag, go to the tag archive and, if the site is using fancy permalinks, add “/feed/” to the end of the url. If it’s not using fancy permalinks, add “&feed=rss2″ instead. You can tell a site is not using fancy permalinks if the tag archive URL is like this: http://[site-url]/?tag=tag_slug (i.e. it contains a “?”).
For example: the URL for any posts tagged with WordPress on this site is:
The non-fancy-permalink version would be:
Now to get an RSS feed for that tag you change the URL like this for fancy permalinks:
Change the non-fancy permalink like this:
For search, it’s slightly simpler as there does not seem to be a fancy permalink for searches. So do a search for wordpress on my site (you can use the searchbox up there in the top). You’ll end up with a URL like this:
Now just add “&feed=rss2″ to the end and you get a feed for any posts on my blog that mention wordpress.
This feed will pick up any post I happen to mention the word “WordPress” in.
Quite neat isn’t it? Now if there was some proper template tags for these feeds I’m sure more themes would natively support them.
What’s the use of using a search rss feed over a tag rss feed? Well you want your blog posts the way you want to read them don’t you? For example, I do not always tag any post about TDOMF with TDOMF. I only tag thoses posts with TDOMF that are relevant to users of TDOMF. But you might want to know everything and anything about TDOMF, so you could use the search rss feed to keep up to date!