Skip to content

Commit 57f595e

Browse files
committed
is_admin() condition added
1 parent 16faa67 commit 57f595e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Posts/exclude-category-from-archive.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
add_action('pre_get_posts', 'my_exclude_category_from_archive');
44
function my_exclude_category_from_archive($query) {
55
// Exclude from the main archive, but display on the category archive
6-
if($query->is_main_query() && $query->query['category_name'] !== 'custom-category-slug') {
6+
// 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') {
78
// Put category ID in the array
89
$query->set('category__not_in', array(10));
910
}

0 commit comments

Comments
 (0)