WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#14344 closed defect (bug) (worksforme)

wp_dropdown_categories, show_count=1 counts unpublished posts as well

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

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)

comment:1 scribu4 years ago

Does wp_list_categories() behave the same?

comment:2 dcowgill3 years ago

  • 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.

comment:3 dcowgill3 years ago

  • Keywords wp_list_categories added
  • Version changed from 3.0 to 3.1

comment:4 scribu3 years ago

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

comment:5 follow-up: mdawaffe3 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 mdawaffe3 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.

comment:7 mdawaffe3 years ago

  • 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.

comment:8 mdawaffe3 years ago

Related? #14788

Note: See TracTickets for help on using tickets.