Exclude Categories From WordPress Feeds

Martin Brinkmann
Jul 3, 2009
Updated • Dec 14, 2012
Development
|
6

I received an email from Matthew a few hours ago who asked if there was a possibility to exclude certain categories from my website from appearing in the RSS feed. I was really busy with a website that I purchased earlier this morning and could not answer immediately. The good news is that it is possible to exclude categories from WordPress RSS feeds.

The bad news is that it might not work with all WordPress blogs and that the user who wants to exclude the categories needs to know their category ID. The first problem is easier to solve. Excluding categories from WordPress feeds works if the WordPress blog is not using the Feedburner feed redirection plugin or a comparable plugin. The feed redirection plugin redirects all feed requests (no matter if they are category specific or the full feed) to an RSS service like Feedburner. This prevents that users can create individual feeds based on categories, authors or tags. It also prevents the exclusion of categories in the feed.

Finding out the category IDs of a WordPress blog is the second obstacle. Most webmasters use pretty permalinks which do not display IDs on the website. The only way to find out without asking the website owner is trial and error. Is is possible to open categories with their IDs in WordPress even if the Pretty Permalinks option is enabled. To open a category with a category ID one would open the following url in a web browser:

https://www.ghacks.net/index.php?cat=23

This would open the Linux category here at Ghacks. This can be a very time consuming process as I have seen categories with five digits. So its probably best to ask the administrator about the category IDs. (Feel free to post additional solutions in the comments).

To exclude categories from RSS feeds in WordPress one would use the following syntax:

https://www.ghacks.net/feed/?cat=-23

This removes category 23 from the main feed of the website. It is possible to exclude multiple categories from the feed, simply append an & and another cat=-xx in the end:

https://www.ghacks.net/feed/?cat=-23&cat=-9592

This excludes the Linux and Mac categories from the RSS feed.

Update: The above option no longer works. To exclude categories from a WordPress feed use the following syntax:

https://www.ghacks.net/feed/?cat=-28,-7724,-11447,-30

where 28, 7724, 11447 and 30 are the categories you want to exclude. You can use the same methodology to merge category feeds into one. Just remove the - from the cats to do so.

Advertisement

Previous Post: «
Next Post: «

Comments

  1. Debajyoti Das said on April 24, 2010 at 4:42 pm
    Reply

    The code used to exclude multiple categories from feeds doesn’t work. :( However, if you changed it to this, it works:
    http://domain.com/feed?cat=-x,-y,-z

  2. David Ruzicka said on October 4, 2009 at 12:42 pm
    Reply

    Hi, would you know by any chance how to do that with tags? These don’t work:
    https://www.ghacks.net/feed/?tag=-14
    https://www.ghacks.net/feed/?tag_ID=-14
    Tx for any advice!

    1. Martin said on October 4, 2009 at 1:52 pm
      Reply

      David i have not found a way to do that.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.