Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#24187 closed defect (bug) (duplicate)

Parent Category Count Update

Reported by: vivekjain's profile vivek.jain Owned by:
Milestone: Priority: normal
Severity: normal Version: 1.5
Component: Taxonomy Keywords:
Focuses: Cc:

Description

WordFlow:
When I assign a child category to a post then its automatically gets appended with the respective Parent category. The post appears in for both, parent as well as the child category.

Bug:
Only the child category count is updated and not the parent category's.

Environment:
Tested on latest version, and on fresh install.

Change History (4)

#1 @vivek.jain
12 years ago

  • Keywords needs-testing reporter-feedback removed

#2 follow-up: @knutsp
12 years ago

  • Component changed from Validation to Taxonomy

I think it's by design that the count is only for posts explicitly connected to that category. You can move a category to another parent, and in such case it would involve a huge recount on sites with many posts.

There are two alternatives, besides "fixing" it in core:

  1. Always add the parent category when a child is added, manually or enforced through a plugin.
  2. A plugin that lets you recount, counting also child category posts. Possibly forcing a complete recount when the hierarchy is changed by moving or deleting a child category.

Expect a wontfix. IMO.

#3 in reply to: ↑ 2 @SergeyBiryukov
12 years ago

  • Milestone Awaiting Review deleted
  • Status changed from new to closed
  • Version changed from 3.5.1 to 1.5

Replying to knutsp:

I think it's by design that the count is only for posts explicitly connected to that category.

Correct. This was previously discussed in #1062.

There's a pad_counts parameter in get_terms() for retrieving the counts including child terms:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/taxonomy.php#L1152

The parameter can also be passed to wp_dropdown_categories() and wp_list_categories(), although it's not documented there:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/category-template.php#L323
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/category-template.php#L429

Always add the parent category when a child is added, manually or enforced through a plugin.

Related: #16397.

Closing as a duplicate of #1062.

#4 @SergeyBiryukov
12 years ago

  • Resolution set to duplicate
Note: See TracTickets for help on using tickets.