How to Exclude Categories from Your RSS Feed


There may be times when you want something to be published on your blog but not on your RSS feed, may be that is some sort of news section or anything. This hack helps you get the power to exclude certain category from your RSS feed, so whenever you publish a new post, it won’t be shown in your RSS feed. This might help some.

Procedure:

Note: Do take backup of your theme before you try this.

01. In order to continue with this tutorial, you have to go through previous tutorial:
How To Find Post IDs in WordPress

Now just like posts ID’s, go your wordpress dashboard and open Category section. Just hover your mouse and get the number after cat_ID=. We will need it later.

02. In your WordPress Admin panel go to Appearance => Editor.

03. Then choose function.php.php file from right hand side and add search for this code:

<?php endwhile; ?>

And add below code (replaced with your ad code) immediately before above code:

function myFilter($query) {
if ($query->is_feed) {
$query->set('cat','-7'); //Don't forget to change the category ID
}
return $query;
}

add_filter(‘pre_get_posts’,’myFilter’);

04. Replace 7 with your category ID.

Advertisements
  • Halaman

  • October 2010
    M T W T F S S
    « Sep   Nov »
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • RSS 20 Newest Free

  • RSS Brothersoft

  • RSS New Software

  • AntiVirus

  • Status Anda

    IP
  • Pengunjung

    free counters
  • Blog Stats

    • 332,125 hits
  • Add to Google Reader or Homepage Subscribe in NewsGator Online Add to netvibes Subscribe in Bloglines Add to fwicki Add to Webwag Powered by FeedBurner

  • Friends Link

  • RSS Kompas

    • An error has occurred; the feed is probably down. Try again later.
  • RSS Lowongan Kerja Terbaru 2013

    • An error has occurred; the feed is probably down. Try again later.
  • RSS Unknown Feed

    • An error has occurred; the feed is probably down. Try again later.
  • Info Tentang AQ

  • Meta

  • %d bloggers like this: