WordPress Categories to the Body Class CSS Plugin

I needed to make CSS changes to a specific category on one of my WordPress sites, this plugin is the result. My WordPress side project started off as a simple review blog and then evolved into more than it was supposed to be. Because of this, I ended up with categories where I should have had custom post types. Rather than making the custom post types and converting the posts over I used this quick fix to make a certain category display much differently than the rest.

Download Plugin

To be fair and give credit where credit is due – the code came directly from this blog post by Philip Newcomer and I put it into a plugin rather than adding it to my theme’s functions.php file.

Here is Philip’s description of the code:

Here’s a little function that will add each of a post’s categories to the body class of the single post page (assuming your theme uses the body_class template tag)..

To see how to make plugins instead of editing your theme’s functions.php file check out this blog post by Brian Hogg.

Leave a Reply

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