We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6673ff9 commit 034a40bCopy full SHA for 034a40b
Posts/excelude-category-from-archive.php
@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+add_action('pre_get_posts', 'my_exclude_category_from_archive');
4
+function my_exclude_category_from_archive($query) {
5
+ // Exclude from the main archive, but display on the category archive
6
+ if($query->is_main_query() && $query->query['category_name'] !== 'custom-category-slug') {
7
+ // Put category ID in the array
8
+ $query->set('category__not_in', array(10));
9
+ }
10
+}
0 commit comments