Opened 5 years ago
Closed 4 months ago
#53383 closed defect (bug) (invalid)
bug: pre_get_posts modify vs posts (pages, etc) found numbers
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Posts, Post Types | Keywords: | has-screenshots |
| Focuses: | administration | Cc: |
Description
Dear WP!
I'm pretty sure I've just found a bug. I want to hide certain posts, pages, media elements and custom post type posts from users. These posts are filtered by their IDs with a pre_get_posts action. The filter itself works well, but the displayed found numbers (on the top of the page) are invalid. On the bottom it's ok again.
<?php function mod_func($query) { if (is_admin()) { if (($pagenow == 'edit.php') && (get_query_var('post_type') == 'page')) {\ $query->set('post__not_in', array(5800)); } } } add_action('pre_get_posts', 'mod_func', 999);
Screenshot:
https://webgeek.hu/wp-bug-post-counter.jpg
Hope you can understand me, I'm not the best in English.
If you have questions, feel free to ask me.
Thanks for helping in advance (and thanks for working hard for years),
Sincerely,
Somogyi Balázs
Attachments (1)
Change History (2)
#1
@
4 months ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
- Version 5.7.2 deleted
AFAIK, view counts are not updated when you apply a filter to the WP_List_Table like you are doing
To manipulate views, you need to do this manually using this hook:
https://developer.wordpress.org/reference/hooks/views_this-screen-id/
wp post counter bug