How To Exclude A Category From Your Blog Feed

diffenereWho is your core target audience? Your feed subscribers? Your search engine visitors? Both categories? If both of them are your target, it may occur that you don’t want them to see everything you write. Taking into consideration the explosion of paid review companies, bloggers are tempted to write posts for money, posts which are not always on the topic of their blog.

If you are in this situation and you fear your feed readers may be offended by your paid reviews, you can choose not to show them these posts.

All you need to do is add several code lines to the functions.php file in your theme:
function myFilter($query) {
if ($query->is_feed) {
$query->set('cat','-5');
}
return $query;
}
add_filter('pre_get_posts','myFilter');

In the above code, you need to replace category number with the correspondent on your blog (for this purpose, you’ll need to define a category for all paid reviews you are going to write).

Source of inspiration: Zeo

3 Comments

  1. Posted October 17, 2007 at 11:56 pm | Permalink

    very nice tip…

    although i only did my first paid post, i was worried about this issue…

  2. Posted October 18, 2007 at 1:54 am | Permalink

    I thought of you when I wrote this post, Pearl ;) It is better not to make people unsubscribe because of the sponsored reviews.

  3. Posted October 20, 2007 at 4:53 pm | Permalink

    I am going to work on it this weekend … thank you so soo much :)

2 Trackbacks

  1. [...] How To Exclude A Category From Your Blog Feed - Exclude a category from a WordPress feed [...]

  2. [...] How To Exclude A Category From Your Blog FeedExclude a category from a WordPress feed [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*