Wordpress Tip: Get an RSS feed from a Tag and from a Search!
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:
http://thedeadone.net/tag/wordpress/
The non-fancy-permalink version would be:
http://thedeadone.net/?tag=wordpress
Now to get an RSS feed for that tag you change the URL like this for fancy permalinks:
http://thedeadone.net/tag/wordpress/feed
Change the non-fancy permalink like this:
http://thedeadone.net/?tag=wordpress&feed=rss2
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:
http://thedeadone.net/?s=wordpress
Now just add “&feed=rss2″ to the end and you get a feed for any posts on my blog that mention wordpress.
http://thedeadone.net/?s=wordpress&feed=rss2
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!
Guest
March 27th, 2008 at 5:23 pm
You say in the template that you can track comments via the RSS feed. Does that work?
Administrator
March 28th, 2008 at 2:06 pm
Hi Jim, most certainly. I use it all the time on Wordpress blogs that don’t provide any other way to track comments.
November 27th, 2008 at 7:47 am
[...] transformar categorias e tags em feeds usando os termos: wordpress “tag rss feed”. Clicando no primeiro resultado descobri que poderia transformar categorias e tags em feeds apenas acrescendo o URL da tag ou [...]
Guest
April 29th, 2009 at 11:15 am
Hi, I’m wondering. Is it possible to create a single RSS feed for multiple search words? e.g. South Africa Education. What will it look like?
thanks
Administrator
May 5th, 2009 at 2:03 pm
Multiple search words? Yes of course.
If they have fancy permalinks turned on, it’s be something like this:
http://thedeadone.net/search/South+Africa+Education
This would give you a search of “South” “Africa” “Education” on a Wordpress blog.
http://thedeadone.net/search/South+Africa+Education/feed
And this would give you a feed.
I think, without fancy permalinks, it’d be
http://thedeadone.net/?s=South+Africa+Education
and
http://thedeadone.net/?s=South+Africa+Education&feed=rss
June 1st, 2009 at 2:36 am
[...] create a feed just for posts that would of interest to the Planet Code4Lib aggregator. I found this useful tip at thedeadone.net on how to do this. I simply tag posts with “planetcode4lib” and then add the word [...]
Guest
January 13th, 2010 at 6:34 am
What about multiple tags?
Great outline btw, thanks.