Last active
August 9, 2016 12:38
-
-
Save waynebcox/d66c70cbe15b04e9ebc6db2326f6a91d to your computer and use it in GitHub Desktop.
[ Genesis ] Add body class based on category slug
This file contains hidden or 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
//* Add new body class based on post category | |
add_filter('body_class', 'wc_category_class_single'); | |
function wc_category_class_single($classes){ | |
global $post; | |
if(is_single()) { | |
$category = get_the_category($post->ID); | |
$slug = $category[0]->slug; | |
$classes[] = 'post-category-'.$slug; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment