Opened 15 years ago
Closed 11 years ago
#11847 closed defect (bug) (fixed)
wp_tag_cloud counts terms attached to future posts when used with custom taxonomies
Reported by: | anonymized_5614834 | Owned by: | filosofo |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9.1 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
If you create a custom taxonomy, then attach some terms from that taxonomy to a future scheduled post, attachments attached to a future post, or unattached attachments, they will get counted toward the totals used to draw the tag cloud produced by wp_tag_cloud.
As a result, the sizes of the items in the tag cloud will be wrong, and the tooltips will show the wrong count. In some cases, if a particular term is only attached to future posts, clicking on the link in the tag cloud will result in a 404 because the main $wp_query correctly filters out future posts and unattached attachments when looking at the term's archive.
Correct behavior would be for get_terms to provide an option to filter out future posts and unattached attachments from its results the same as is done when looking at the term's archive.
Attachments (1)
Change History (8)
#2
@
15 years ago
- Resolution duplicate deleted
- Status changed from closed to reopened
Reading the ticket again, I was definitely too quick to mark this as a limitation of taxonomies, versus an actual bug.
#3
@
15 years ago
- Milestone changed from Unassigned to Future Release
The problem with this is, That the count is only of the terms usage, So if a term is used on an attachment, draft post, page, or published post, it'll increment that counter.
unfortunately, that leads to the problem whereby, the term is used, but not on a visible object.
On the term archive, Its a different story, That ignores the count field, it queries wp_posts directly for all the posts that match (criteria, published post, etc) and exist within the (term of taxonomy) relationship table.
#4
@
15 years ago
I actually implemented a workaround by adding a filter on get_terms in my plugin (eidogo-for-wordpress). When I call wp_tag_cloud I add a parameter which the filter looks for. It then does a count for the terms restricting post counts the same way the term archive does.
I've attached the relevant filter function in case it's useful to anyone else running into this.
Closing this a duplicate of #10142. See also this comment in #9674.