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!
You say in the template that you can track comments via the RSS feed. Does that work?
Hi Jim, most certainly. I use it all the time on WordPress blogs that don’t provide any other way to track comments.
[…] 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 […]
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
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
[…] 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 […]
What about multiple tags?
Great outline btw, thanks.
I had no idea you could do this! Does it still work with WP 3.1?
I think so, but I haven’t yet explicitly checked.
@JesusGallent http://thedeadone.net/blog/wordpress-tip-get-an-rss-feed-from-a-tag-and-from-a-search/
You can check the following plugin:
http://wordpress.org/extend/plugins/selected-tags-rss
It allows blog readers to enable separate RSS feeds covering different combinations of tags.