#29745 closed defect (bug) (duplicate)
Post count incorrect for shared custom taxonomy in context of post type
Reported by: | jchristopher | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description (last modified by )
I found other tickets that may tackle a variation of this issue, but they seem to focus on post_status
as opposed to post_type
— hoping this isn't a dupe of the following:
I have a custom taxonomy (collection
) that I'm sharing among two custom post types (product
and lookbook
). Products are part of a Collection, and each Collection has a Lookbook, so each 'lookbook' shares a 'collection' term with a 'product'.
I believe there's a bug concerning the Count when viewing the Collections term list when in context of Products vs. Lookbooks.
For example, I have created a single product
with a collection
term of 'Fall':
When viewing Collections under the Products CPT menu, the Count column is accurate:
However (even though I haven't added any Lookbooks yet) when I view Collections under the Lookbooks CPT menu I assume that these counts will represent the counts of that CPT ('lookbook'), but it appears to simply retrieve the count stored in the database, which is an overall count of term usage, not limited to any particular post type:
Clicking the count brings you to a CPT listing page filtered down to the Fall collection
term as expected, with no posts (expected), but the original count of 1 is incorrect:
I've included a patch but would love to hear what you think about a better approach to this. I considered whether adjusting get_terms()
to accept a post_type
parameter was acceptable but it didn't seem like an appropriate place to make an adjustment like this.
Attachments (2)
Change History (8)
#1
@
10 years ago
It occurs to me that with an abundance of posts this won't be ideal performance-wise. Any suggested improvements are much appreciated.
Update: updated patch to utilize WP_Query's found_posts
to help with a large volume of posts.
#4
follow-up:
↓ 5
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
Correct taxonomy term Count when filtering by post type