Ultimate WordPress RSS Feed Customization

Updated this post to reflect Matt’s comments and replace /wp-inst/wp-rss2.php by /feed/.

Just extending on Lorelle’s Customozing RSS Feed Links for WordPress.com and WordPress Sidebar Widgets which provides useful suggestions for customizing WordPress feeds, even for searches. Reading that article made me delve into more ways of syndicating specific content. Feed templates can also be modified for more granular control. If feeds are still Greek to you, Introduction to Syndication and WordPress Feeds will bring you up to speed.

Now, more customization for RSS feeds in WordPress! WordPress executes the WordPress Loop and the associated queries for producing the feeds. This implies that rules that apply for creating index, archive, searchor custom queries can be used for creating the feeds. It is kind of single-source publishing, same queries to be used for same content, irrespective of whether it displayed on the web or syndicated via the feed.

Let us see what this means for us. In addition to the default feeds, now we can provide additional partial feeds for posts created using WordPress queries, e.g., posts for last two days or order posts alphabetically or posts by a specific author in a multi-author blog. Say, one of your visitors is interested only in two categories and not all of them. Using this blog as an example, lets create a feed for categories blogging and wordpress.

All the examples given below are relative URLs with respect to the root of the blog, i.e., the URLs displayed below are appended to http://iface.wordpress.com/.

feed/?category_name=blogging
&category_name=wordpress

We have specified the category names as arguments to the file wp-rss2.php which produces the RSS feeds. If you are not afraid of handling IDs, the same result can be obtained using:

feed/?cat=91+33

Here, 91 is the category ID of the category blogging and 33 that of wordpress. This is so convenient for my reader who would otherwise had to subscribe to the entire feed and filter through the posts or subscribe to two feeds, one per category. This would be intolerable if the reader was interested in 10 categories out of 20.

Now consider a case where your visitor is interested in 9 out of 10 categories, that is you want to eliminate posts for one category from the feed. I am trying document all WordPress global variables on this blog, and all of them are filed under the wordpress global variables category. A reader, not interested in the WordPress plugins or theme development, might not interested in the wordpress global variables category posts. Here is how it can be done:

feed/?cat=-80413

will remove the posts under wordpress global variables in this blog.

Techniques mentioned in Alphabetizing Posts can be used on the query, e.g.,

feed/?cat=91+33&orderby=title&order=asc

will result in the feed having alphabetically ordered posts.

feed/?authorname=anadgouda

will produce a feed for posts by me, even if there were more authors writing on this blog.

If it is useful, feeds can also be produced for pages, following are multiple ways:

about/feed

feed/?pagename=about

feed/?page_id=2

While all the above examples can be used for a WordPress.com blog, they are applicable even to an independent blog. As a blog owner, you can probably create such feeds for specific readers of your blog.

WordPress gives you the ability to customize the RSS feeds by letting you run customized queries, this gives the ultimate power to the blog owner and the reader.

Technorati tags: , ,

Copyright Abhijit Nadgouda.

About these ads

9 Responses to “Ultimate WordPress RSS Feed Customization”

  1. Matt Says:

    Please don’t use wp-inst in any URLs, it could break at any time. You can use /feed/ URLs for all of your examples above.

  2. Abhijit Nadgouda Says:

    Thanks for the clarification Matt, I will update the examples accordingly.

  3. links for 2006-04-19 | Shanta Rohse Says:

    [...] Ultimate WordPress RSS Feed Customization I am always looking for ways to read less, not more. Abhijit Nadgouda’s primer for customizing RSS feeds explains how to provide customized partial feeds for posts by running customized queries. We’re one step closer to personalized content. (tags: RSS wordpress personalization guides) [...]

  4. Abhijit Nadgouda @ iface » Merging Blogs Says:

    [...] If you feel that you don’t want to read about the programming posts, you can subscribe to this feed which does not include the posts under programming category. Head over here for more customization. [...]

  5. August Says:

    Is there a parameter to limit the number of posts from a category? Let’s say I only want the 5 most recent posts from a category.

  6. Abhijit Nadgouda Says:

    Hi August,

    WordPress lets you specify the number of posts in a feed in the admin area on Options -> Reading page under Syndication Feeds. This is retrieved from the database.

    It cannot be controlled through the query. Hope this helps.

  7. Ken Says:

    I would like to keep my existing full text feed (run through the feedburner plugin), but create a seperate title-only feed for use via RSS include in another web site (so that it will just list the titles w/ links).

    Do you have any suggestions as to how to do that?

  8. Robert Eckert Says:

    This is really a nice way to find neat blogs on the internet.I was searching for a particular query when your blog popped up in the search engines.I guess you just have to put together a organized web site.

    Great blog either way.I will definitely will bookmark you for future reference.Recently I came across a fantastic way to get targeted traffic to any blog or web site with amazing results.Time tested and proven to increase web site traffic at least 400%.

    Best of all they offer a JV Program that can create really fantastic residual income.Many have used this program in the past and now are called Super affiliates.I encourage you and your readers to check it out.Have a Great Day!

    http://www.webtrafficsecret.com


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: