Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

acosmin on "Exclude category from the main RSS feed and also keep that category feed"

$
0
0

If you want to exclude a category from the main RSS feed and also keep that category rss feed use the following code:

function ac_exclude_from_rss($query) {
    // Categories to exclude - by ID
    $cats_to_exclude = array( 15, 16);

    if ($query->is_feed && !$query->is_category($cats_to_exclude) ) {
        set_query_var('category__not_in', $cats_to_exclude);
    }

    return $query;
}
add_filter('pre_get_posts','ac_exclude_from_rss');

If someone has something to add please share :)


Viewing all articles
Browse latest Browse all 8245

Trending Articles