I would filter pre_get_posts
. Perhaps like so, though you may need to tweak the conditional a bit:
function wpse71508_filter_pre_get_posts( $query ) {
if ( is_main_query() ) {
if ( is_home() || is_archive() ) {
$query->set( 'cat', '-22' );
}
}
return $query;
}
add_action( 'pre_get_posts', 'wpse71508_filter_pre_get_posts' );
If you could clarify the context (rather than the template file) to which you want to apply this query modification, I can be more specific.