Created
January 11, 2016 20:27
-
-
Save ashleyfae/9fc364cf86dc4100e10e to your computer and use it in GitHub Desktop.
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
/** | |
* Exclude a specific category from your RSS feed. | |
* | |
* @param WP_Query $query | |
* | |
* @return WP_Query | |
*/ | |
function exclude_category_from_rss( $query ) { | |
$cat_id = 0; // Change this to be the ID of the category you want to exclude, but put a - in front. Example: -99 | |
if ( $query->is_feed ) { | |
$query->set( 'cat', $cat_id ); | |
} | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'exclude_category_from_rss' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment