#29850 closed defect (bug) (invalid)
Theme Function Filter disables Admin Dashboard Post Filter
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | minor | Version: | 3.9.2 |
| Component: | Query | Keywords: | |
| Focuses: | administration | Cc: |
Description
I have following filter in my theme functions.php to exclude post from an Archive Widget:
function exclude_category($query) {
if ( $query->is_archive ) {
$query->set('cat', '-26,-1,-57,-58');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');
However, this disables the filter by category on the Posts-page (../wp-admin/edit.php). Removing above code from theme functions.php the Post-page filter works as it is intended to do. This is new as the Posts-page filter used to work on an earlier version of WP with above code in the theme functions.php.
Surely theme filters should not take precedence over the wp-admin pages.
Change History (2)
Note: See
TracTickets for help on using
tickets.
'pre_get_posts'runs in the admin too. You should add anis_admin()check to your function.It's also a good idea to add a
$query->is_main_query()check.