A better body-class function for WordPress

UPDATE– Jan. 25, 2015: moving the parent page name checks into the conditional statement to avoid silent errors // UPDATE– Oct. 20, 2013: Thanks to Marty (see comments below), for convincing us to change out our method for body classes to filter the default WP body_class() function instead of creating our own. It still gives you all the advantages of our original function plus the classes you get by default.

Here’s what it does


Add this stuff to your functions.php file, or just use our html5 shell and it’s built in.


Your Help

Let us know if you see ways to make it better, probably more conditions could be added to the beginning to take into consideration more template types.

Topics covered:
Enable Javascript