WordPress.org

Ready to get started?Download WordPress

Forums

Can't figure out excluding categories on RSS (7 posts)

  1. bigvibes
    Member
    Posted 2 years ago #

    I've looked through the forum and found this code, which I input into my functions.php file to try to exclude a few categories from RSS. It's not working though. Could there be a conflict between WordPress RSS feed and Feedburner? I run both and the Feedburner feed does exclude the categories because I've gone into their system and excluded them. But the original feed still shows everything. I can't figure it out. Any ideas? thanks

    I'm running a child theme and this is the complete content of that file:

    <?php

    function myFilter($query) {
    if ($query->is_feed) {
    $query->set('cat','-317, -1, -487, -691');
    }

    return $query;
    }

    add_filter(‘pre_get_posts’,'myFilter’);

    ?>

  2. Frumph
    Member
    Posted 2 years ago #

    Try this, instead of your current if area:

    if ($query->is_feed && !is_category()) {
    		$query->set('category__not_in',array(317,1,487,691));
    
    	}

    Inside your code.

  3. bigvibes
    Member
    Posted 2 years ago #

    Uh uh. That totally took down my website....

  4. Frumph
    Member
    Posted 2 years ago #

    FTP in and fix it.

  5. bigvibes
    Member
    Posted 2 years ago #

    I did go in and fix the site so it's working again, but the feed issue is still there.

  6. Frumph
    Member
    Posted 2 years ago #

    .. did you update a post after adding that code to the functions.php ?

    The feed is cached until a post updates.

  7. bigvibes
    Member
    Posted 1 year ago #

    My apologies, it turns out the original code was working for me. Some posts were just really delayed for some reason.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.