#15806 closed defect (bug) (worksforme)
get_terms with hide_empty returns count > 0 with unpublished items
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Taxonomy | Keywords: | reporter-feedback needs-unit-tests bulk-reopened |
Focuses: | Cc: |
Description
Hi,
I think that's a bug.
I've defined a custom post type and a custom category taxonomy for it.
On my front end, i'm using get_terms with hide_empty to show the categories of the existing custom post type.
get_terms does ignore unpublished posts but it seems to include trashed item.
I have one category that is linked to only a trashed item and the function includes it in the count.
I can't select 3.0.3 in the version dropdown but it happened on any 3.0.x that I tried.
Attachments (1)
Change History (15)
#2
@
14 years ago
- Cc neo@… added
- Keywords changed from taxonomy, custom post to taxonomy custom post
#3
@
14 years ago
- Summary changed from get_terms with hide_empty returns count > 0 with trashed items to get_terms with hide_empty returns count > 0 with unpublished items
I could also reproduce this bug with posts pending approval. Their tags/categories shouldn't show up in the front end if those tags/categories are otherwise unused by published posts. Even better would be for get_terms to have an option specifying desired post status, "publish" being the default value.
#5
@
14 years ago
Just ran into this same problem. Custom post type with custom taxonomy, custom taxonomy returning results with posts in trash.
#6
@
14 years ago
- Cc jgadbois added
Seems like either a join will be needed in get_terms() or wp_update_term_count_now() will need to be modified to only count terms tied to published posts. This second method will also require counts to be updated when post status changes.
I'd be happy to look at this one...anyone want to chime in as to which approach would be preferred?
#7
@
13 years ago
- Cc paudelvinay added
- Severity changed from minor to major
- Version changed from 3.0.2 to 3.2.1
Is there any progress on get_terms with unpublished post/private posts for custom taxonomy?
#8
@
13 years ago
- Version changed from 3.2.1 to 3.0
Version number indicates when the bug was initially introduced/reported.
#9
@
12 years ago
- Cc wpcore@… added
- Resolution set to worksforme
- Status changed from new to closed
I tried to reproduce this bug in version 3.6-alpha-23791 and it appears to be working correctly now.
#11
@
9 years ago
- Resolution worksforme deleted
- Status changed from closed to reopened
- Version 3.0 deleted
The problem is still present in 4.5.3 (with custom taxonomy and custom post type)
#12
@
9 years ago
- Keywords reporter-feedback needs-unit-tests added
- Milestone set to Awaiting Review
- Severity changed from major to normal
- Version set to 3.0
@fetard Hi, can you provide the code you're using and/or steps to reproduce this issue?
#13
@
9 years ago
I can't reproduce the issue .15806.diff includes tests for a number of situations, all of which seem to work as expected: 'draft' posts are excluded, posts that transition from 'publish' to 'draft' are excluded, posts that transition from 'publish' to 'trash' are excluded.
In his comment above, @ocean90 asked for details to reproduce. Specifically, it would be helpful to see the code used to register the post type and taxonomy. If the post type is providing its own update_count_callback
, then it needs to be responsible for its own resetting of term counts.
#16
@
6 years ago
- Keywords bulk-reopened added
- Resolution set to worksforme
- Status changed from reopened to closed
Closing as per https://core.trac.wordpress.org/ticket/15806#comment:13
In 3.2 I could also reproduce the bug with an unpublished post in combination with an otherwise not assigned custom taxonomy term. (get_terms w/ hide_empty)