How to add Category Name as class(s) in body tag

The body_class wordpress filter is nice for adding a lots of classes to the body tag that have information about what kind of page is currently being displayed. Probably for styling purposes. But for whatever reason, it doesn’t include a class for the current category (or categories) for a single post.

This following code adds all categories as classes in <body> tag

Filter Used

 

Leave a Reply

Your email address will not be published. Required fields are marked *