I'm trying to build a tree layout for a custom taxonomy. Categories are animals.
Big Game (0) -- Bears (2) -- Black Bear (3) -- Grizzly Bear (2)
The above is a glimpse of what I have. CURRENTLY, A "post" can be categorized as a child category (Black Bear, Grizzly Bear) without being part of the parent (Bears) or other ancestor (Big Game). The parentheses indicate the # of posts in that category.
What I want is for a post to be added to it's parent categories when created or updated. How would I do this? Ideally I would have ended up with this automatically.
Big Game (5) -- Bears (5) -- Black Bear (3) -- Grizzly Bear (2)
I figured this has been done before... however I can't seem to find the answer on my own. Thanks!
Edits for clarity
Given the above example of a custom Animal Taxonomy, what I need is for a post to be added to it's parent category by default. As geomagas pointed out, the point of hierarchical taxonomies is that the child is implicitly part of it's parent. However, what I need is for it to be explicitly a member of the parent post.
Here is the ideal scenario: A user is editing ora creating a new post. He or she would write the post, and then categorize the post as "Grizzly Bear" by placing a checkbox next to the category before hitting update. After hitting update the post would have a checkbox next to Bears and Big Game, indicating it is a member of both.
But wait... Bonus clarity! : If a user updated a post and categorized it as a Bear, it would be added to Bear and Big Game, but not Grizzly Bear because that is a child category.
More bonus clarity: I have double checked and this is not default behavior. In my situation, if I get posts by taxonomy Animals that have the term Bear, Grizzly Bear posts would not be included. I would have to go in and manually set Grizzly Bear posts to be part of Bear and Big Game queries.
Hopefully that helps Thanks! PS I'm pretty close to figuring this out myself and I'll update with the answer if I get it first :)