I have multiple categories on my site. With widget logic, I'm able to show the widget on the category and single posts within that category, BUT if the category has a subcategory, when I click on that, the widget no longer shows.
MAIN CATEGORY: Dogs
- Food post (under "Dogs")
- Adopting post (under "Dogs")
- Training post (under Dogs/Poodle)
- Health post (under Dogs/Poodle)
Where my main category id=3, this widget logic code will make the widget appear for anything under the "Dogs" category
is_category(3) || (is_single() && in_category(3))
I can expand it to also include the subcategory, by just adding to the code
is_category(3) || (is_single() && in_category(3)) || is_category(6) || (is_single() && in_category(6))
but is there a better way to do it? I'd like it to be automatic, so that when I'm adding a new subcategory, the widget automatically shows up because it is under category 3 (Dogs).
Thanks for your help!