Excluding Category from Main Page in WordPress

I’ve added the following custom code that I found on Zeo’s blog.  It gets added to the functions.php section of the theme being used (Theme Functions) for the blog.  Which obviously will require it to be updated each time I change the appearance of the blog.  But it’s simple.  I found a relatively complicated plugin which didn’t work and still required manual editing of the file.  If you’re aware of a functional plugin to do the same thing (preferably with a list of check boxes) I’d appreciate the pointer.

My goal here is to be able to maintain all my blog entries in one place, but allow me to write some technical entries that would otherwise bore my lay person reader (all three of them).

I also want to find a way to make a custom page to show all of the tech entries.  Off to search for that.


function exclude_category($query) {
  if ( $query->is_home || $query->is_feed ) {
    $query->set('cat', '-54');
  }
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

Leave a Reply

Your email address will not be published. Required fields are marked *