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!
One comment
Pingback: Removing a Category From Your Feed in WordPress | AlienBabelTech