Monday, September 20, 2010

TutZone- Tutorials, Design news and Inspiration

TutZone- Tutorials, Design news and Inspiration

Link to TutZone

How to Exclude Categories from Your RSS Feed

Posted: 20 Sep 2010 07:19 AM PDT


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.
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.

No comments:

Post a Comment