I need to display an intro paragraph on an archive page that displays all posts in the parent and child categories. I’m adding the required content via a sidebar widget and I have code that displays it correctly.
if( is_category( '28' ) || get_sidebar('blog-intro'));
The problem is the side bar widget also displays on all child pages for category 28 => 28/a, 28/b,… I need it on just category 28. Any ideas on how I can filter that out?
The actual category id of a category archive is in the global $cat.
On further lowering of expectations, I think allowing the widget to display on all blog archive pages but not on single posts is acceptable.
But I’m still curious about the answer.
I’d look into
get_category()
If I recall correctly,
$cat->parent_category()
will return 0 if it’s a top level categorySo: