How To Exclude A Category From Your Blog Feed

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

This entry was posted in Tutorials, Wordpress and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

4 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 :)

  4. Posted September 27, 2010 at 8:20 am | Permalink

    Great tips site! I am curious whether the code could still be working or not.

2 Trackbacks

  1. By Bookmarks for Friday, January 11th — Trevor Fitzgerald on January 11, 2008 at 8:31 pm

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

  2. By Bookmarks for Monday, April 7th — Trevor Fitzgerald on April 8, 2008 at 12:03 am

    [...] 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 *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting



  • Connect with Violeta here:


  • Get your FREE tips and tricks:

    Delivered by FeedBurner

  • Disclosure: I am compensated for some of my reviews. Click here for details.