How To Exclude A Category From Your Blog Feed

CPAWay - free to join affiliate network

CPAWay - free to join affiliate network
Who 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

4 Comments

2 Trackbacks / Pingbacks

  1. Bookmarks for Friday, January 11th — Trevor Fitzgerald
  2. Bookmarks for Monday, April 7th — Trevor Fitzgerald

Comments are closed.