[wp-trac] [WordPress Trac] #14084: Custom taxonomy count includes draft & trashed posts

WordPress Trac noreply at wordpress.org
Fri Feb 22 15:33:44 UTC 2013


#14084: Custom taxonomy count includes draft & trashed posts
-------------------------------------------------+-------------------------
 Reporter:  lumpysimon                           |       Owner:  garyc40
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Taxonomy                             |  Review
 Severity:  normal                               |     Version:  3.0
 Keywords:  has-patch 3.2-early dev-feedback     |  Resolution:
  needs-refresh                                  |
-------------------------------------------------+-------------------------
Changes (by jeremyclarke):

 * cc: jer@… (added)


Comment:

 I can confirm that the count of terms in custom taxonomies still includes
 draft posts.

 Setting `'update_count_callback' => '_update_post_term_count'` fixed the
 problem for me.

 I see no reason why `_update_post_term_count` shouldn't be the default
 behavior. I don't think most people consider the mechanism that generates
 "term count", and would not expect it to behave differently between the
 built in taxonomies and a custom taxonomy with no `update_count_callback`
 specified.

 '''My Details'''

 We have posts that we are keeping as drafts and they had terms from our
 custom taxonomy. The tag cloud, because it looks at the term's ->count,
 was showing these terms even though the only post they were applied to was
 a draft. The site is new and has a term for every country on earth, many
 of which have no posts yet. The result was a tag cloud full of links to
 archive screens with zero posts, a terrible result.

 After setting `'update_count_callback' => '_update_post_term_count'` and
 resaving each draft post the tag cloud was fixed.

 This is a very subtle bug because most of the time you would never notice.
 If there is at least one post in each term then their archives are never
 actually empty, so the mistake isn't as toxic when you get linked to zero-
 post screens. If you publish all posts in a timely manner there's no
 reason you'd ever notice the brief period where the tag from your draft
 was in the sidebar.

 That said this bug probably affects the majority of people who use custom
 taxonomies, just by a small enough margin that it doesn't bother them. Why
 not fix it in the background? Anyone who really cares about how the term
 count is generated probably has their own callback for it right?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14084#comment:31>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list