Customized WordPress RSS Feed

By Lewis Wolfe, Monday, April 21st, 2008

Here’s a very simple hack to exclude items from an RSS feed, and since the principle involves the Loop, by extension, for post output as well - it’s not great programming style or practice but it does the job.

Exclude by author - any post you don’t want to appear on the RSS (maybe you’re a bit shy about sponsored posts…) assign to their own author.

You could also exclude by category, but the programming is slightly more complicated, since get_the_category() returns an array of objects

In, for example, wp-includes/feed-rss2.php

In the Loop: - while( have_posts()) : the_post();

add: if (get_the_author_ID() != 3){ // the chosen author ID to exclude

and don’t forget the closing } just before endwhile;

And, 3-4 months later, don’t forget to switch user…

In the same way, this is the first step towards setting up a featured posts category…

1 response so far

  • C. Douglas said

    Perfect timing on this one! I was going “loopy” in the middle of the night — forgot to close! Thanks once again!

Leave a comment

Want a gravatar?
gravatars
Go to gravatar.com and upload your preferred avatar.

Your comment *

RSS feed for comments on this post. TrackBack URI