Skip to content

Instantly share code, notes, and snippets.

@mladenp
Created May 30, 2014 11:49
Show Gist options
  • Save mladenp/d47a5af15b63f066baa6 to your computer and use it in GitHub Desktop.
Save mladenp/d47a5af15b63f066baa6 to your computer and use it in GitHub Desktop.
Add class to body of WP
// category id in body and post class
function category_id_class($classes) {
global $post;
foreach((get_the_category($post->ID)) as $category)
$classes [] = 'cat-' . $category->cat_ID . '-id';
return $classes;
}
add_filter('post_class', 'category_id_class');
add_filter('body_class', 'category_id_class');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment