Tom – oh dur, I didn’t even notice that! That’s much easier, thank you!
@pracko – Now I remember why I did the body class, it’s a special case – I’m adding something special after page headers for style purposes, Tom’s solution is probably a better jumping off point. Or, if you really want to group headers & use my code to create body classes based on those groupings, you could use a plugin like Advanced Custom Fields to add a field to page headers (say, a drop-down with categories, select a category) & pick it up in that code / add a body class accordingly.
Wow, that is super awesome Tom. I really think this will be useful with sites that have multiple departments/sub-sections/areas and that also have a number of different post types or custom post types within each area of the site. This way, the page headers linked together with a unique class can be used as a unique page taxonomy for overall page styling purposes within that site area. Cheers!
OK, having a custom function to add the class to the body tag would work too. That way the entire group of pages could be more easily styled to be consistent with each another.