Forums

[resolved] exclude a category from rss (15 posts)

  1. brett
    Member
    Posted 5 years ago #

    I was wondering if there is an easy way to exclude a category from rss. I have a category that provides the content for a future event calendar but I don't want those posts to show up in the rss. Can anyone help me out?
    Thanks, Brett

  2. welsper
    Member
    Posted 5 years ago #

    Type "exclude rss" in that search box up there. You'll find a post with the same title as this one... hint hint hint.

  3. brett
    Member
    Posted 5 years ago #

    True, but there isn't really an answer in that post, it just says add $cat="-15" to the wp-rss2.php file. That might make perfect sense to the person that posted it, but if you just randomly insert it into the php file, it will throw an error. Does it go in a loop? Does the -15 correspond to which specific category to exclude? Just for the sake of taking the post at its word, I just added that line to the php file and it breaks the php. Any help would be appreciated.
    Thanks, Brett

  4. brett
    Member
    Posted 5 years ago #

    Thanks, that did the trick. I was just one line too soon in the file when I tried before.

  5. danny_butt
    Member
    Posted 4 years ago #


  6. danny_butt
    Member
    Posted 4 years ago #

    Hi Brett or anyone, can you please tell me where exactly to put $cat="-15" in the wp-rss2.php file? It looks like someone replied to Brett and it got deleted. Would really like this info as have searched the web to no avail - have got the category excluded from the frontpage but not the RSS :7. Thanks!

  7. Kafkaesqui
    Moderator
    Posted 4 years ago #

    danny: In your wp-rss2.php locate this line near the top:

    require('wp-blog-header.php');

    Put $cat="-15" right above it, like so:

    $cat="-15";
    require('wp-blog-header.php');

  8. danny_butt
    Member
    Posted 4 years ago #

    fantastic! Thanks so much Kafkaesqui. I probably could have worked that out with a week's mucking around, and very relieved not to...

  9. XratedFozzibaer
    Member
    Posted 4 years ago #

    I use WordPress 1.5.3 and tried the suggestion above to exclude a categorie from the rss2 feed, but it didnt't work.
    There are still all categories in the rss2 feed.
    ???

  10. Beel
    Member
    Posted 4 years ago #

    If you did a search you'd quickly find this recent thread:
    http://wordpress.org/support/topic/39698

    see if that works.

  11. XratedFozzibaer
    Member
    Posted 4 years ago #

    Yeah that's it!
    I allreday read this post, but didn't realise it's potential.
    Thanks for your hint!

  12. bartman316
    Member
    Posted 3 years ago #

    You said:

    In your wp-rss2.php locate this line near the top:

    require('wp-blog-header.php');

    Put $cat="-15" right above it, like so:

    $cat="-15";
    require('wp-blog-header.php');

    The problem for me is that my wp-rss2.php does not have this line of code. There is a section of code on this page that says:

    if (empty($wp)) {
    require_once('wp-config.php');
    wp('feed=rss2');
    }

    but that is it. Can anyone please help me to disable one category from the RSS feed I've tried every solution that came up in the search for "exclude RSS" and it just won't work. Is there something different I should be using with 2.0??

  13. bartman316
    Member
    Posted 3 years ago #

    anyone?? i'm getting frustrated. I think I've tried every possible solution posted.

  14. Kafkaesqui
    Moderator
    Posted 3 years ago #

    "You said"

    Actually, *I* said it, but nineteen months ago, back when some hacks worked better than others.

    This works:

    if (empty($wp)) {
    $cat = -15;
    require_once('wp-config.php');
    wp('feed=rss2');
    }

    *If* one accesses the feed script directly (i.e. blog/wp-rss2.php), but not through a GET query (blog/?feed=rss2, or blog/feed/rss2 using custom permalinks). For the latter, add the following line to the index.php in your blog's root directory (and not to your theme's index.php):

    if( isset($_GET['feed']) ) $cat = -15;

    Just make sure to put it between the <?php and ?> tags, somewhere before wp-blog-header.php is included.

  15. bartman316
    Member
    Posted 3 years ago #

    Sorry for my frustration but I'm having a lot of trouble with this considering how it seems to be such a simple fix.

    I've tried both of these suggestions after reading through all of the other related forum threads and still am having no luck with either blog/wp-rss2.php or blog/?feed=rss2. Is there something else I may be missing?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.