WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#24187 closed defect (bug) (duplicate)

Parent Category Count Update

Reported by: 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)

comment:1 vivek.jain12 months ago

  • Keywords needs-testing reporter-feedback removed

comment:2 follow-up: knutsp12 months 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.

comment:3 in reply to: ↑ 2 SergeyBiryukov12 months 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.

comment:4 SergeyBiryukov12 months ago

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