Exclude Categories From Wordpress Feeds - gHacks Tech News

Exclude Categories From WordPress Feeds

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.





  • We need your help

    Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

    We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.

    If you like our content, and would like to help, please consider making a contribution:

    Comments

    1. 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.

    2. 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

    Leave a Reply