• Resolved samdari

    (@samdari)


    My site is indianexaminer.com. In the upper left, there’s a link: “Stay Connected > Latest Posts in RSS (menue opens up with all the category feeds”. I would like to exclude certain feeds from showing up there.
    I’ve tried using the following code in my functions.php but it just messes everything up in that file and the site goes down.

    function my_cat_exclude($query) {
    if ($query->is_feed) {
    $query->set(‘cat’,’-ID1,-ID2,-ID3′);
    }
    return $query;
    }

    add_filter(‘pre_get_posts’,’my_cat_exclude’);

    I also tried using Advance Category Excluder but it does not work!

    I’m guessing using the right code in the right php file (header.php or functions.php ?) I can get it done. I can post the needed php files, if you need more insight.
    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    The code you are using is to excludes categories from the MAIN RSS feed. That is not what you want to do.

    You want to exclude single category feeds from the dropdown list of available category feeds. Looking in your theme’s header.php file it appears the code to change is around line 61:

    <ul>
       <?php
       $categories = get_categories('hide_empty=1');
       foreach ($categories as $cat){

    try changing it to this (where 10, 13, 17 are the categories to exclude from the dropdown menu list)

    <ul>
       <?php
       $categories = get_categories('hide_empty=1&exclude=10,13,17');
       foreach ($categories as $cat){

    Thread Starter samdari

    (@samdari)

    Sorry for the late reply stvwlf. Your suggestion did the trick :-). Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Code to hide category feeds’ is closed to new replies.