Created
January 27, 2016 11:50
-
-
Save roscabgdn/effa90aa3383d58923c6 to your computer and use it in GitHub Desktop.
WordPress - add category class 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
add_filter( 'body_class', 'body_class_example' ); | |
function body_class_example( $classes ) { | |
if( is_single() ) { | |
foreach( get_the_category( get_the_ID() ) as $category ) | |
$classes[] = 'cat-' . $category->category_nicename; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment