Opened 9 years ago
Last modified 4 years ago
#30250 assigned enhancement
Add filter for query used in `wp_count_posts()`
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Use case: if my list table is filtering to a specific taxonomy term, I'd like my view counts to reflect that filter.
The existing filter added in #16603 still means I need a lot of duplicate code, and two queries.
Attachments (1)
Change History (8)
#2
follow-up:
↓ 6
@
9 years ago
I'm not sure about this approach. The line with the counts is above the filters. Therefore, it's not on the same level.
What you are proposing is to add All/Draft/Pending/Published as another filter category. For me, it would make more sense to move the line with the counters below the filters then. And you need an additional "Reset filters" button then.
This is what the current All/Draft/Pending/Published links are acutally doing: resetting the filters!
So, I would be reluctant to include your proposal. But I'm far from being a core developer :-)
#6
in reply to:
↑ 2
@
8 years ago
- Keywords needs-patch added; has-patch needs-testing needs-refresh removed
Replying to minderdl:
I'm not sure about this approach. The line with the counts is above the filters. Therefore, it's not on the same level.
I think this ticket is about a custom list table built by a custom query, not about the All dates/All categories filters.
30250.diff does not seem like a correct solution here.
We should introduce something like 'posts_clauses' filter, but specific to the query in wp_count_posts()
.
We could also add a third parameter, $args
, and use WP_Query to get post IDs and use them in the WHERE
clause, but that seems out of the scope of this ticket.
Partial solution.
Do not count properly for sticky posts.
Why?
Sticky post are counted in different place.
But if this direction is ok, just help me to finish this task.
How handle this different place?
wp-admin/includes/class-wp-posts-list-table.php
line 83?