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 https://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 https://webgrrrl.net/feed to https://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 https://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
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.

Spread the love

Check out my other posts: « / »

Posted on 8 July, 2007 under Discovering WordPress

8 comments

  1. Zaiaku says:

    I find myself updating my htacess all the time. Especially when trying to simply file links and pages. Glad you got it working for you.

  2. RT Cunningham says:

    Hi Lorna,

    I just tried this plugin today (the latest version). While it stopped the category I wanted from showing up in the feeds, it caused recent posts to show up three times in the browser. Really weird. I wish I could figure out which file controls the feeds because I’d go right there and edit it by hand — actually, I’d probably write a function modifier in my theme.

    1. Lorna says:

      RT, I read the comments in the plugin web site, and from what I can gather, the posts appear that way when you select more than one category for the posts. Wasn’t clear whether using Exclusion may or may not solve the problem.

  3. Aha! I understand, but it’s very odd that it works that way. By the way, I was mistaken. One post was triplicated while the sponsored post was still there and it’s the one that I excluded.

    I’ll have to dig into it again. In the meantime, I’m using a snippet of code in theme’s function.php file to try to do it the easy way. Or, at least I think it’s easier. I’ll let you know.

    1. Lorna says:

      I see it affected your feed as well. Your Dancing Inmates post appeared 7 times!

  4. RT Cunningham says:

    Oops, I downloaded the old version — no wonder it hosed things up. I downloaded the “beta” version and so far so good. I did a resync with Feedburner, but nothing has changed yet, like it did when it hosed everything.

  5. FINALLY! I’ve been looking for a plug-in that would allow me to put a post into multiple categories and have it filtered out. But I’m still not sure if this means that the post will be seen by a search bot in all categories or not? I would not want it to be seen in more than once place by the robot, but by the users.

    1. Lorna says:

      Hmm, then I think you would have to set a robots.txt or .htaccess on that one, because I think the most this plugin will do is to manipulate what your users will or will not see.

Comments are closed.