Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#16397 closed feature request (wontfix)

Selecting Sub-Category should select parent category.

Reported by: sterlo's profile sterlo Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: General Keywords:
Focuses: Cc:

Description

If you have the current structure:

  • Category A
    • Child Category B

Currently in WordPress if you put any posts into the child category, it will treat as though it's also a part of the parent category.

Meaning that if I don't specifically select the parent category and I just select the child category and save...if I do a query on the parent category - it will have increased in value.

Would it not make sense to have it automatically select all parent categories of a child category when selecting what categories a post belongs to?

Change History (6)

#1 @markjaquith
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Some people use parent categories as mere containers, and don't ever want things to show that parent category when the list of categories for that post is output. I don't see this changing — it would be unexpected behavior for a lot of people.

It would be fairly trivial to write a plugin that accomplished this behavior, however. If someone writes one, link to it from this ticket!

#3 @sterlo
14 years ago

I submit this UseCase without any plugins installed:

Created a parent category and a child category:

mysql> select * from wp_terms; select * from wp_term_taxonomy;

Results (terms):

term_idnameslugterm_group
22omgwtfbbqomgwtfbbq0
23lulzlulz0

Results (taxonomy):

term_taxonomy_idterm_idtaxonomydescriptionparentcount
2222categoryThis is a parent category.00
2323categoryThis is a child of omgwtfbbq.220

I then created a post! Actually...I created three.

One that belongs to the parent category.
One that belongs to the child category (parent no selected).
One that belongs to both.

Now...the terms show up as thus:

select * from wp_term_taxonomy;
term_taxonomy_idterm_idtaxonomydescriptionparentcount
22|22categoryThis is a parent category.02
23|23categoryThis is a child of omgwtfbbq.222

So this reflects your expectation in the form of data.

But if I ask WordPress if the Parent category has posts in it:

$test=get_posts('category_name=omgwtfbbq');
echo count($test);

Result: 3

So if we're going to treat it as though it actually has 3 posts in it...why not...actually have 3 posts in it?

I understand we can right a plugin to "fix" problems. Or we could ... fix the problems.

If this is not a problem, I will defer to your judgment.

Version 0, edited 14 years ago by sterlo (next)

#4 @sterlo
14 years ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

#5 follow-up: @markjaquith
14 years ago

  • Resolution set to wontfix
  • Status changed from reopened to closed

The default has been that querying the posts in a category queries posts in all subcategories. But there is a difference between being implicitly in a category (due to heritage) and being explicitly in a category (due to user selection). If we checked all parent categories, the distinction between implicit and explicit would be lost.

Consider the hierarchy A > B > C > D. If selecting D selects C, B, and A, a user would have to deselect four boxes to remove a category from D. Or if you do that for them, the interface becomes twitchy when they want a category to be in B and D, but not A and C. People would also suddenly have a lot more categories be shown on their entries — categories they had previously just used as containers.

Real life example: I have Tech, with subcategories WordPress, Photography, and Apple. Tech is for general tech stuff. If it relates to WordPress, Photography, or Apple, I put it in that (but do not select Tech). All four categories' content shows up when browsing to category/tech/. If Tech were automatically selected when I selected WordPress, all WordPress posts would say: "Categories: Tech, WordPress" It's redundant information. And it's not how I categorized it. In the above example, every D post would say: "Categories: A, B, C, D." Every C would say "Categories: A, B, C." If you want a breadcrumb display, you should do that specifically, not have the category system dump every parent in the list along with the explicit category selections.

#6 in reply to: ↑ 5 @sterlo
14 years ago

Replying to markjaquith:

The default has been that querying the posts in a category queries posts in all subcategories. But there is a difference between being implicitly in a category (due to heritage) and being explicitly in a category (due to user selection). If we checked all parent categories, the distinction between implicit and explicit would be lost.

Thank you!

Note: See TracTickets for help on using tickets.