Last active
December 16, 2015 10:19
-
-
Save rozklad/5419037 to your computer and use it in GitHub Desktop.
WP: add category to body_class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// TODO: rewrite as filter | |
$class = array(); | |
$prefix = 'category-''; | |
foreach(get_the_category() as $category) { | |
$class[] = $prefix . $category->slug; | |
$class[] = $prefix . $category->cat_ID; | |
} | |
?> | |
<body <?php body_class( $class ); ?>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment