• WPChina

    (@wordpresschina)


    I am trying to use this RSS URL to only display certain categories, but it’s not working:
    https://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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter WPChina

    (@wordpresschina)

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

    Thread Starter WPChina

    (@wordpresschina)

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Weird RSS issue showing categories that shouldn’t be there…’ is closed to new replies.