Make WordPress Core

Opened 15 years ago

Closed 14 years ago

Last modified 14 years ago

#14344 closed defect (bug) (worksforme)

wp_dropdown_categories, show_count=1 counts unpublished posts as well

Reported by: 1manfactory's profile 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)

#1 @scribu
15 years ago

Does wp_list_categories() behave the same?

#2 @dcowgill
14 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.

#3 @dcowgill
14 years ago

  • Keywords wp_list_categories added
  • Version changed from 3.0 to 3.1

#4 @scribu
14 years ago

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

#5 follow-up: @mdawaffe
14 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().

#6 in reply to: ↑ 5 @mdawaffe
14 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.

#7 @mdawaffe
14 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.

Note: See TracTickets for help on using tickets.