If..Else Log

Feeding the masses using WordPress

When I decided to segregate the (sporadic but more substantial) main posts from the frequently updated shorts on If..Else, I’d neglected to pay adequate attention to the feeds.

Whilst you could choose to subscribe only to the shorts via the category feed, there was no opportunity to receive only the main articles in your feed reader. The main feed was an intermingled mess of both the shorts and the regular entries, which dampened the effectiveness of the arrangement.

If you take a look at the subscription page now, you’ll see that things are altogether more useful. The seperate feeds should make things more manageable for subscribers.

Seperating the feeds

Out of the box, WP supports category feeds. Accessing these ‘inclusive category’ feeds is fairly straightforward; just append /feed/ to the end of the category page. However, what it doesn’t offer is an ‘exclusive category’ feed , that is a feed that syndicates all posts except those from a particular category (in my case, excluding posts from the shorts category).

However, implementing an exclusive category feed is fairly simple. To exclude a category, what you’ll need to do is open up your root index.php and add the line $cat=-n (where n is the category id). Make sure that you’re editing the file in your blog root and not your theme’s index.php and that you add it before the import of wp-blog-header.php i.e. http://example.com/index.php and not http://example.com/wp-content/themes/your-theme/index.php

What you should have is something like this:
code

Whilst this works, you’ll find that in it’s present state, it’s not quite ideal. We’ll need to do a little more work before this is usable.

Mixing the feeds

The problem with the above technique are that:
a) the entries for this category will be excluded from the main blog loop (which may or may not be what you want)
b) you may still want to offer a full feed with all the works intermingled together.

One way in which you can do that is by passing a parameter to specify the type of feed required. We can then handle that as is appropriate.

Firstly, what we’ll need to do is try to work out if the user is requesting a feed instead of a page. In WordPress, all the work goes through the index.php file in your blog root. When a feed is requested, a parameter called feed is passed as part of the URI.

After we verify that it is a feed being requested, we can then check what type of feed is being requested. In my case, I’ll be offering main, shorts and a full feed. Turning this into code gives us the following
code

Icing the feeds

Now we don’t want to link to the feeds with unfriendly query strings. What we should be doing is making non crufty URI’s for the feed. That means it’s mod rewrite time.

I’ve decided on the following format:

All posts http://ifelse.co.uk/feed/
Main entries only http://ifelse.co.uk/feed/main/
Just the shorts http://ifelse.co.uk/feed/shorts/

Now to do this, you’ll need to open up your .htaccess file and add the following (ideally above the line ‘# BEGIN WordPress’).
code

Presenting the feeds

Finally, I’ve decided to not link to the feeds directly. Instead, I’ve given them their very own page. The reason for doing so are two fold.

Firstly, not everyone knows what a RSS feed is. I’ve borrowed some of the ideas from D Keith Robinson’s page on the matter to give a short blurb on what it does and how you can use them.

Secondly, by grouping them up in a single page, I can provide a bit more information on the different feeds.

Finally, the feeds are still linked in the page header. This means that it’s still discoverable by feed readers and browsers.

Tasting the feeds

Finally, I’ve got a question/favour to ask of you guys. I gather that a few of you are subscribed to the feeds. Unfortunately, whilst I can measure the popularity of web visitors, I don’t have any way of measuring how many people or how popular the feeds are.

So my questions are:

  • Which of the offered feeds are you currently subscribed to?
  • Do you prefer segregated feeds?
  • Which type of entries do you prefer/read? The shorts or the mains? (Don’t worry, i don’t mind:-))
  • What feed readers do you use?

If you don’t want to comment, feel free to drop me an email.

Also, any other thoughts/suggestions on the matter?

-30-

19 Responses to “Feeding the masses using WordPress”

  1. Gravatar João Craveiro

    Which of the offered feeds are you currently subscribed to?
    All posts.

    Do you prefer segregated feeds?
    Yes; and, for some blogs, I also miss the ability to subscribe one single feed with both posts and comments.

    Which type of entries do you prefer/read? The shorts or the mains?
    Prefer both, read both — although the shorts suffer of the normal “blog content replication”, whereas the effect “non-shorts” are more unique, and thus more enjoyable to read through.

    What feed readers do you use?
    Liferea (Linux only)

  2. Gravatar Phu

    Thanks for that João. Much appreciated.

    “although the shorts suffer of the normal blog content replication”
    I know what you mean and it’s been troubling me as well. I’ll try to do less of that in future:-)

  3. Gravatar Podz

    I get the complete feed, and I would continue to do so regardless of how you split your feeds to offer out.

    I always get the full feeds because I think that while feeds don’t give us the complete picture – only a site visit does that – they do help us build a picture. But the picture of you that I build is based on what you publish, and what you publish will already be but a small part of you. If I then choose to read only one part of that part, then why am I reading your feed ? I could get information from elsewhere surely ?

    I can see that only a certain category of post may interest someone so they take the feed of that and only that, but for me that reduces you to a news source. While that may be true in a tiny part, this is a personal blog and I feel it should be treated as such.

    A longer post every so often, or single ‘asides’ frequently – the latter tells me more and in many ways is more interesting.

    It’s a whole blog, so I’ll have the whole feed :)

  4. Gravatar Podz

    Oh.. FeedDemon :)

  5. Gravatar Phu

    Ahh… I love FeedDemon. Well worth the £15 or so that I paid for it.

  6. Gravatar Brendan

    I prefer full feeds, and I am subscribed to “the lot”.

    Like Podz, I prefer to get an overall feel for where a blogger is coming from – segregating content on a web page can have a powerfull effect – in a feed? Not so much.

    There are a lot of bloggers who still persist in not providing full feeds – with the idea I’ll visit the blog to ‘read the rest’. In actual fact I will seldom visit that blog and most likely unsubscribe. If a post interests me, believe you me I will visit to comment (like this one).

    Just tell me you won’t switch away from full feeds and I’ll be a happy chappy. :)

  7. Gravatar Brendan

    ehm, crap – I use Thunderbird.

  8. Gravatar David

    I subscribe to the full feed, and will probably still do so. It’s nice to have the option of separate feeds though. I prefer “proper” entries – this one, for example, was especially handy. I’m currently using Sage for Firefox, although I may go back to FeedDemon if it doesn’t work out. Ok so far though.

  9. Gravatar Ben

    I’ve been doing the same for a while now on my site. I got the idea for the seperate links and articles thing from you :)

    However I think my way for seperating the feeds is better… It’s pretty obvious really, just send cat=-whatever in the rewrite rule. That way you don’t have to go and modify things each time you upgrade WP. So the rewriterule for my articles (minus links) is

    RewriteRule ^feed/articles/?$ /index.php?&feed=feed&cat=-4

    Oh… I generally subscribe to the ‘everything’ feeds, and I use Firefox and Sage

  10. Gravatar Phu

    “Just tell me you won’t switch away from full feeds and I’ll be a happy chappy”
    I get annoyed by the lack of full feeds as much as you do, so no worries on that front.

    “just send cat=-whatever in the rewrite rule”
    Ahhh, you’re right Ben. That’s probably a better idea:)

  11. Gravatar indi

    Gudfly has a category visibility plugin that simply lets you check off the categories you want to exclude from your feed, which accomplishes one of your goals, though not all

  12. Gravatar btree999

    Nothing better than WP :)

  13. Gravatar Scott

    I just ran across this and want to thank you for a very elegant solution to a problem I was looking to solve. Unfortunately, as with everything, I have a question.

    For some reason no matter what I do I always end up getting a 404 error if I surf to /feed/main/ when I set this up on my site. If I surf to index.php?&feed=rss2&type_of_feed=main then everything works just fine. So, that leads me to believe that there is something wrong with my .htaccess file. Here is what I put in mine:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^jarkolicious.com [NC]
    RewriteRule ^(.*)$ http://jarkolicious.com%{REQUEST_URI} [R=301,L]
    RewriteRule ^(feed)/main/?$ /index.php?&feed=rss2&type_of_feed=main [QSA,L]
    RewriteRule ^(feed)/asides/?$ /index.php?&feed=rss2&type_of_feed=asides [QSA,L]
    RewriteRule ^(feed)/full/?$ /index.php?&feed=rss2&type_of_feed=full [QSA,L]

    It is the very first thing in my .htaccess file. The “BEGIN WordPress” portion is down a number of lines in the file.

    Any ideas how to solve this? I appreciate and help you can offer. Thanks in advance.

  14. Gravatar Rk

    Hi,
    I have a simple requirement. I tried to use all sorts of combinations but nothing seems to work.
    I want to exclude a certain category from main page but I want those posts included in the main feed.
    I tried a variation of your code or this but the posts are getting excluded from both places.Request you to help, thanks in advance.

  15. Gravatar kapeka

    Hi,

    nice thing you coded here. The Problem is, that I have the same Problem like scott. If i try /feed/main or /feed/shorties I always get error 404. Simply /feed/ works without problem. And the long URL is working for all three.

    GFS

  16. Gravatar Bruce

    Ben at Binary Moon says the rewrite rules that worked in WP 1.x broke for WP 2.x. I finally worked out a solution that will give me a summary feed with all categories, and a full-text feed with one category excluded, described here.