Customize Your WordPress-Feeds

WordPress offers several different feeds for your reader, but not always is their desired format available.

In some cases the reader has the desire to receive just specific news of a website and not all of them. WordPress is flexible enough to meet these requirements. How you can implement this via function in a theme is very easy. I will show you some code snippets and explain it to you.

Template tag query_posts is very powerful and can help you in this matter. There is no change in your core files necessary.

For a better understanding of the concept I will give you some basic information to feeds in WordPress.

WordPress offers four feed formats RDF, RSS 0.92, RSS 2.0 and ATOM 1.0 (since WP V2.*). As a standard, they create feeds in posts, comments and all content in archive – like categories or tags. Some examples for understanding.

  • normal feed (Permalinks inaktive) for RDF:
  • normal feed (Permalinks inaktive) for RSS:
  • normal feed (Permalinks inaktive) for RSS2:
  • normal feed (Permalinks inaktive) for Atom:
  • normal feed (Permalinks aktive) for the tag example in RSS 2 format:
  • normal feed (Permalinks aktive) for RDF:
  • normal feed (Permalinks aktive) for RSS:
  • normal feed (Permalinks aktive) for RSS2:
  • normal feed (Permalinks aktive) for Atom:
  • normal feed (Permalinks aktive) for the tag example in RSS 2 format:

Now you like to create a feed based on categories and also create a feed, excluding categories. All examples are based on the RSS2 format, but it’s easy to use any other format for these example.

  • Feed of the category with ID 23:
  • Feed of the category with ID 12, 13, 23:
  • Exclude category with ID 23 in this feed:
  • Exclude categories with ID 12, 13, 23 in this feed:

Especially the second example shows how you can mix the different categories easily. Very useful if you have a website with quite a lot topics to offer. So you can create feeds for different reader groups.

This form of creating specific feeds is pretty easy but we don’t have a function yet which we could use. But the themes in WordPress allow some kind of extension to use a function for creating specific feeds. You have to put the function in functions.php of your theme. Here an example:

function fb_cat_exclude($query) {
    if ($query->is_feed) {
    return $query;


The above example creates a function which gets feeds from all areas except categories with ID 12, 13 and 33. With the help of filter hooks it gets delivered to the query. And with the help of conditional tag is_feed() the categories will be only exclude in a feed.

This gives you a pretty powerful tool, the reader gets only the news you like to give him. For all other content he has to visit your website. It is pretty flexible and you can control the content in your feeds. You are able to meet special requirements if you need to.





5 responses to “Customize Your WordPress-Feeds”

  1. Jen Avatar

    Thank you for the tips on WordPress feeds.

  2. Alex Avatar

    Our pleasure Jen!

  3. onsetonair Avatar

    Hi, this looks quite interesting. When I get my feeds working, I’ll probably use that.

    Would you know how to get my feeds working in wordpress? It keeps saying that the URL doesn’t exist and I don’t know how to create it.

  4. Frank Avatar

    I think, you have an error in your install, you have not content in your feed. Maybe; copy all files and folder of WP new,not overwrite, new copy.

  5. Jason Avatar

    When I place the fb_cat_exclude function in functions.php if excludes the categories for RSS2, RDF and ATOM but not RSS. Any ideas?

    function fb_cat_exclude($query) {
    if ($query->is_feed) {
    return $query;