WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Remove certain categories from site RSS feed (5 posts)

  1. RichardSapien
    Member
    Posted 4 years ago #

    Hello,

    I've done some research but I can't seem to find what I'm looking for. I would like to prevent posts from a specific category from appearing on the site's RSS feed.

    Is this doable? Any hacks/plug-ins? I appreciate your help.

    RS

  2. This plugin's comments includes a way to deal with categories in feeds. Looks like you could tweak your feed without the plugin, too.

  3. Arnold Goodway
    Member
    Posted 4 years ago #

    You will need to place something like this in your functions.php file:

    function myFilter($query) {
        if ($query->is_feed) {
            $query->set('cat','-99');
        }
    return $query;
    }
    
    add_filter('pre_get_posts','myFilter');

    The number 99 refers to the index of the category you want to exclude from the feed. Do not forget to add the minus before the number you are going to put in here.

    Hope this helps.

  4. RichardSapien
    Member
    Posted 4 years ago #

    Great suggestions, I got it working. I really appreciate your help guys.

  5. DoZ
    Member
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic