Removing a Category From Your Feed in WordPress

If you run your site on WordPress and using it as a content management system, you may have realized that there are categories of posts that you don’t want published on your feed.  There is no easy way to do this through WordPress by default, but that doesn’t mean that this isn’t possible to accomplish.  You can eliminate certain categories easily by editing your theme’s functions.php file.

1. Edit your theme’s functions.php file
2. Paste the following code between the <?php and the ?>

// --------------------------------------------------------------------------
// Start Category Remove from Feed
// --------------------------------------------------------------------------
	function myFilter($query) {
	    if ($query->is_feed) {
	        $query->set('cat','-289'); //Don't forget to change the category ID =^o^=
	    }
	return $query;
	}

	// 289 = Press Releases Category

	add_filter('pre_get_posts','myFilter');
// --------------------------------------------------------------------------
// End Category Remove from Feed
// --------------------------------------------------------------------------

Note: These functions are not of my own creation, simply things I have found along the way.  If you are the author of this function, please let me know so I can properly credit you with your work!

About Joe D

I have always had a passion for everything computing. In early 2000, I decided to take my passion to the web. Thus, C.O.D. was born. Through the years we have made many great friends at C.O.D. and hope to continue our journey for years to come.

Check Also

Manage Multiple WordPress Sites with InfiniteWP

Running your website, or websites, on WordPress is an easy choice as the flexibility the …

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.