Excluding a Category from Archives

Version audio de cet article
add_action('pre_get_posts', 'remove_themespress_post_categories' );
function remove_themespress_post_categories( $wp_query ) {
// 31 = ID de ma catégorie
$remove_cat = '-31';
// supprimer des archives feeds, search, and home page, mais pas admin ou category
if( (is_home() || ( is_archive() && !is_category() && !is_tag() )) && !is_admin()) {
set_query_var('cat', $remove_cat);
}
}We could also used this option via a Query Post. Here are a few examples of Query Posts.