There are certain times when you need to include or exclude certain categories in the feed or search results. The easiest way to take care of this is to add the following to your functions.php file.
function sdac_remove_from_feed( $query ) {
if ( $query->is_feed ) {
$query->set( 'cat',-1 );
}
return $query;
}
add_filter( 'pre_get_posts','sdac_remove_from_feed' );
The code above will exclude all posts that are in the category with ID 1 from your feed. If you wanted to exclude everything from the search results – you would change one line:
$query->is_feed to $query->is_search
If you wanted to only show items from the category with ID 1 – you would just need to remove the “-” before the category number.
Note: You can include/exclude items tagged, etc by changing the ‘cat’ to whatever else you would normally use in the query.

HOWTO: Add a Custom Comment Class to WordPress
1Posted by: Jennifer Zelazny on November 30, 2009
Categorized: SDAC Blog, WordPress, WordPress Logic
Tagged: comment_class, WordPress, WordPress functions
Ever need to add your own class to your WordPress comment template but not sure how because of the function comment_class that controls the classes? Check out the function comment_class and you will see adding your own custom classes very easily.
Allow this sounds pretty basic – it is a lifesaver for doing a lot of customizations.