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 16faa67 commit 57f595eCopy full SHA for 57f595e
Posts/exclude-category-from-archive.php
@@ -3,7 +3,8 @@
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') {
+ // Must add is_admin() so posts are displayed in WP Administration Posts -> All posts
7
+ if($query->is_main_query() && !is_admin() && $query->query['category_name'] !== 'custom-category-slug') {
8
// Put category ID in the array
9
$query->set('category__not_in', array(10));
10
}
0 commit comments