Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#14344 closed defect (bug) (worksforme)

wp_dropdown_categories, show_count=1 counts unpublished posts as well

Reported by: 1manfactory Owned by:
Priority: normal Milestone:
Component: Taxonomy Version: 3.1
Severity: minor Keywords: wp_list_categories
Cc: dcowgill@…

Description

When using the function

wp_dropdown_categories

and setting the argument

show_count=1

Wordpress will also count posts which are not published.

I tested it with different combinations of parent categories and child categories. It is always the same.

I checked on Windows/Apache and Unix/Lamp.

Change History (8)

Does wp_list_categories() behave the same?

  • Cc dcowgill@… added

Yeah, I'm having the same issue with wp_list_categories(). It appears to be missing something like:

$where .= " AND post_status = 'publish'";

I believed it needs to be added in the 'get_terms' function but don't know how to fix it exactly.

  • Keywords wp_list_categories added
  • Version changed from 3.0 to 3.1

Actually, the post count is stored in a dedicated column. See also #14076

comment:5 follow-up: ↓ 6   mdawaffe2 years ago

  • Keywords dev-feedback added

The count column is COUNTed from the term_relationships table, which doesn't know about the statuses of its object_ids.

Fixing would involve filtering the query in wp_update_term_count_now().

comment:6 in reply to: ↑ 5   mdawaffe2 years ago

Replying to mdawaffe:

The count column is COUNTed from the term_relationships table, which doesn't know about the statuses of its object_ids.

Fixing would involve filtering the query in wp_update_term_count_now().

Um... I think I'm lying. I thought I could reproduce, but can't now. Looking more.

  • Component changed from General to Taxonomy
  • Keywords dev-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

OK. I can't reproduce this bug. And this situation is exactly what $taxonomy->update_count_callback is for.

Closing as WFM. If you can still reproduce with WordPress trunk, please reopen with more details.

Related? #14788

Note: See TracTickets for help on using tickets.