Last active
October 5, 2016 17:24
-
-
Save jpmarchand/2b691cb2b6b8bdb07f1e to your computer and use it in GitHub Desktop.
Exclude posts of specific categories from WordPress RSS feed. Source: http://www.jangro.com/excluding-posts-from-your-blog-feed/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Exclude posts of specific categories from RSS feed | |
function customprefix_exclude_categories_rss_feed($query) { | |
if ($query->is_feed) { | |
$query->set('cat', '-5, -11, -18'); // Precede category IDs with a minus sign | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts', 'customprefix_exclude_categories_rss_feed'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment