Forums

Weird RSS issue showing categories that shouldn't be there... (3 posts)

  1. WPChina
    Member
    Posted 3 years ago #

    I am trying to use this RSS URL to only display certain categories, but it's not working:
    http://www.myblog.com/feed?cat=1,2,5,7,9

    I should only see categories 1,2,5,7,9. I do see those, but I also see all my other categories.

    I narrowed down the problem to my functions.php.

    In my functions.php in my theme I have the following to remove the category 16 from the feed and the home:

    <?php
    function myFilter($query) {
        if ($query->is_home || $query->is_feed) {
            $query->set('cat','-16');
        }
    return $query;
    }
    add_filter('pre_get_posts','myFilter');
    ?>

    If I remove that code from the functions.php, my RSS URL above works fine. However when I use that code above, my RSS feed shows everything EXCEPT category 16.

    Any idea what is wrong? Is my code for the omission of cat 16 in the functions.php incorrect?

    Tks!

  2. WPChina
    Member
    Posted 3 years ago #

    sorry to bump, but I can't figure this RSS issue and why the conflict is occurring...

  3. WPChina
    Member
    Posted 3 years ago #

    Nobody else has this problem? My code seems so tight and accurate, so I can't figure out why it is affecting the main RSS feed for the site.

Topic Closed

This topic has been closed to new replies.

About this Topic