Add a category class to single post pageviews and template files
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
// add category nicenames in body and post class
function category_id_class( $classes ) {
global $post;
foreach ( get_the_category( $post->ID ) as $category ) {
$classes[] = $category->category_nicename;
}
return $classes;
}
add_filter( 'post_class', 'category_id_class' );
add_filter( 'body_class', 'category_id_class' );