WordPress feed filtering



At the risk of affecting the credibility of this blog, yes I admit, I finally succumbed to pay-per-post opportunities. You will have noticed it by now after reading the last few posts I made about diets and home improvement matters. Even so, I’ve been looking into ways to filter the posts in my site so that the sponsored posts can be viewed separately from my normal posts, via my web site as well as my feed.

Hyperlinking feeds with query string
My googling led me to ifacethought’s page on RSS feed customization, so I initially contemplated on changing my Feed URL by adding a query string to my RSS icon (see bottom of page); the URL should then be http://webgrrrl.net/feed?cat=-11. However, this does not help my current feed subscribers; it’s too much of a hassle for both myself and my feed subscribers just for accommodating one small change.

Editing my htaccess file
Sifting through the docs and support forum on syndication at WordPress Codex for modifying feed templates just gave me more headache, but I did come across an instruction on how to automatically forward any feed reference to a new feed address. In my case, I wanted to automatically forward http://webgrrrl.net/feed to http://webgrrrl.net/feed?cat=-11. Here are a few of the htaccess directives I have used to no effect:

  • RewriteRule ^feed(.*)? /feed?cat=-11 [QSA] — gave me a huge server error which I have forgotten what it was and am not interested in recalling it, too scary; it may be caused by the question mark being server-parsed as a backreference. I think.
  • RewriteRule ^feed(.*)? /feed?cat=-11 [R,L] — does not change the feed.
  • RewriteRule /feed /feed\?cat=-11 [QSA] — parse the backslash to an HTML encoded URL, therefore the feed doesn’t understand the filter command.
  • Redirect /feed http://webgrrrl.net/feed/?cat=-11 — gave me an error saying that the page took too long to respond; I’m assuming that it’s doing a loop, seeing that /feed/?cat=-11 will call the redirect as well as /feed.

The folks at DALnet’s #linux (thanks, Cancel and tmwk) were kind enough to point me to the mod_rewrite module and I did try to make sense of it, but my mind was just too set on getting a quick fix; tmwk also mentioned that it’s a fragile way of doing a redirect for reasons I did not bother asking.

WordPress syndication plugins, of course
This was the first thing I did actually. I installed and tried Front Page Excluded Categories, which only filters out the categories in the front page display and nothing else. After browsing through the RSS section of the WordPress plugins and doing a search across the WordPress site, none of them really gave me the information I needed. However, I got back to searching again and tried other keywords such as syndication, feed, filter and other, and I eventually came across a reference to RYO Website’s Category Visibility plugin.

Screenshot of the Category Visibility control form.This plugin is amazing, to say the least. Filtering can be done depending on user levels, or whether you want the categories to appear or not appear in the searches, front page, list, feeds, or archives. You can also specify whether a post should appear or not, in case you have it under more than one category, say A, B, and C, and you have specified all post in B to be filtered out. It’s pretty comprehensive, in other words. You need to be aware, though, that once you save your filter settings on feeds, you won’t see the change applied instantly, until you have published a new post. I was scratching my head for a full 6 hours before I noticed my feeds being filtered.

Finally. I almost thought that I would have to develop a plugin of my own to do this sorta thing! :) My subscribers should now be spared of the sponsored post, and any time you’re interested in reading them, just head over to my Other Matters section for some tips and ideas.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>