3

I'm trying to exclude certain categories from the mydomain.com/feed

Researching online I came across this code:

<a href="<?php bloginfo('url'); ?>/feed?cat=-3&cat=-12">Entries (RSS)</a>

Now the question is should I create a function (if yes what function to create) so I can exclude categories without having anyone to redirect to custom feed URLs

6

In your functions.php add:

function excludeFeedCats($query) {
    if ($query->is_feed) {
        $query->set('cat','-3, -12');
    }
return $query;
}

add_filter('pre_get_posts','excludeFeedCats');

Or use Simply Exclude for more flexibility.

0

Take a look on this plugin too Ultimate Category Excluder.i hope it'll helps you:)

  • Thanks for the tip. But I'm not a big fan of plugins anymore.. I already have around 30 plugins.. prefer to use php than plugins. – Sledge81 Jul 1 '11 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.