Brain Food for Web Developers

RSS Feed

Exclude Category from WordPress RSS Feed

A useful little code snippet to remove categories from the WordPress RSS feed.

Just add the following code to your function.php file:

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


This will remove the category with the ID of 12.

Author: Graham

My name is Graham and I'm a Scottish web developer living in California. I love working with clean code to make attractive and usable websites. I'm also interested in cooking, gardening, and taekwondo.


  1. where do I find function.php file?

    • Hi Dave,
      You can find the functions.php file in your theme directory:
      [Wordpress root] > wp-content > themes > [current theme] > functions.php
      I hope this is useful. Let me know if you have any more questions.

  2. Hi Graham, I am new to web design so please excuse my lack of knowledge on this subject. This is perhaps a simple question but how do I know what category number to put in there?

    • Hi Dave,
      Excellent question. WordPress doesn’t make it very obvious what the category ID is. One of the easiest ways to find it is to login to your dashboard and click on Posts > Categories > [Your Category]. Look at the URL in your address bar and you should see something like: ‘edit-tags.php?action=edit&taxonomy=category&tag_ID=12&post_type=post’.
      The part that says tag_ID=12 (may also be cat_ID=12) tells us the category ID.
      I believe you can also install a plugin to display IDs in the admin area:
      I hope this is helpful. Let me know if you have any other questions, I’d be glad to help.