• Skip to main content
  • Skip to primary sidebar
  • Business
  • WordPress
  • Security
  • Marketing
  • Publicity
  • Computing
  • Resources
  • Whatevs

Purely Wordpress

Just The Tech, News, and Info We Deem To Post

  • Home
  • About
  • Contact
  • Contribute
You are here: Home / Code Snippets / Exclude Categories from RSS Feed

Exclude Categories from RSS Feed

Matrix Style Image Representing WordPress Code Snippet

Insert the code snippet into your theme’s functions.php, a helper file, or a functionality plugin to exclude specific categories from being displayed in WordPress RSS Feed results.

X where X is the number/ID of your category, comma separated for multiple

function myFeedExcluder($query) {
if ($query->is_feed) {
   $query->set('cat','-X');
   }
return $query;
   }
add_filter('pre_get_posts','myFeedExcluder');

by Jack Alltrade on September 7, 2022

Filed Under: Code Snippets Tagged With: Categories, RSS Feed, WP Core

Reader Interactions

Share Your Two Cents Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Categories

  • Code Snippets
  • Development
  • File Management
  • Genesis Framework
  • Hosting
  • Legacy
  • Plugins
  • SEO
  • Tech Terms
  • Themes
  • User Experience
  • User Interface
  • WordPress Core
  • WordPress Functionality

Warning! Use at your own risk!

As always, use at your own risk and remember to backup your site prior to inserting new code.

© Copyright Jack Alltrade & Associates 2025 · Purely Supplemental™ is a trademark of Jack Alltrade & Associates