Hi @priscilaps,
Thanks for reaching out.
That one needs to modify the actual header.php and <body> tag which isn’t recommended. You can then add this code to your child theme’s functions.php (appending to the end if there is any other codes).
add_filter('body_class', 'mother_category');
function mother_category($classes) {
if ( is_category() ) {
$this_category = get_category($cat);
if ($this_category->category_parent == 0) {
$this_category->category_parent = $cat;
} else {
$parent_category = get_category($this_category->category_parent);
$ParentCatId = $parent_category->cat_ID;
$ParentCatName = $parent_category->slug;
}
$childcategories = array();
$catx = $ParentCatId;
$cats = get_categories('parent='.$catx);
foreach($cats as $cat) {
$childcategories[] = $cat->term_id; } ;
if( is_category( $childcategories ) ) {
$class = 'child-category-of-'.$ParentCatName;
}
$classes[] = $class;
}
return $classes;
}
I use the code from the URL you have provided and made it work functions.php. This should serve as a guide on how it should be implemented as functions.php’s code and the proper use of body_class as a filter. We can’t cover any further modification of the code, especially it’s not from us 
Thanks!