Forums

Restrict RSS feed to one category (1 post)

  1. annfoley
    Member
    Posted 1 year ago #

    I want to restrict the output of my site's rss feed to one category.

    My feed link looks like this:

    <a href="<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a>

    In addition, I have put this into the functions.php file:

    function fb_cat_exclude($query) {
         if ($query->is_feed) {
         $query->set('cat','-5,-6,-8');
         }
         return $query;
         }
    
         add_filter('pre_get_posts','fb_cat_exclude');

    (I found this functions.php addition in the WP forums and thought it was worth a try.)

    However, when I subscribe to the feed, I get all the posts in every category. I'm pretty new to WordPress & would very much appreciate some suggestions.

Topic Closed

This topic has been closed to new replies.

About this Topic