NB: Make sure you do a back up of your theme, files and database before attempting the tutorials
Intermediate
Last modified : Sep 10 2022
Estimated reading time : 0 minutes, 44 seconds - 84 words
Share the post "Excluding a Category from Archives"
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.