Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#16397 closed feature request (wontfix)

Selecting Sub-Category should select parent category.

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

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
16 years ago

  • Milestone Awaiting Review
  • Resolutionwontfix
  • Status newclosed

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
16 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
2222categoryThis is a parent category.02
2323categoryThis 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.

Last edited 16 years ago by sterlo (previous) (diff)

#4 @sterlo
16 years ago

  • Resolution wontfix
  • Status closedreopened

#5 follow-up: @markjaquith
16 years ago

  • Resolutionwontfix
  • Status reopenedclosed

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