Add category ID to worpdress body tag

Some of yootheme themes are missing this so i think it s important to be able to customize

so if you are missing this this is how to add it

Add this code to your functions.php

// category id in body and post class
function pro_catid_class($classes) {
global $post;
foreach((get_the_category($post->ID)) as $category)
$classes [] = ‘cat-‘ . $category->cat_ID . ‘-id’;
return $classes;
}
add_filter(‘post_class’, ‘pro_catid_class’);
add_filter(‘body_class’, ‘pro_catid_class’);

Nemanja Radevic

Wordpress expert Joomla expert Front end development expert Warp Framework expert Responsive design

Donate to help us continue and write posts to help people out there