Add category class to body for single portfolio items
Hello, i need to add the Portfolio category as a body class on single portfolio pages.
I added the following code below to add the categories on blogpost:
add_filter('body_class','add_category_to_single');
function add_category_to_single($classes) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
// add category slug to the $classes array
$classes[] = $category->category_nicename;
}
}
// return the $classes array
return $classes;
}
But I can't adapt to the Portfolio. Please advise as to how to get this working for portfolio single pages.
Comments
What you ask for, requires files customization what in reference to Item Support Policy is not allowed. So if you want to modify files and don't know how, you should contact your web developer.
thanks