Site icon Hip-Hop Website Design and Development

WordPress show solely youngster class in template

I’ve a weblog with 1 father or mother class and three youngster subcategories.
For technical causes, within the backoffice, after I write an article, I’ve to examine the father or mother AND the kid class.

In each article, I need to show the title of its “direct” class, and never the father or mother.
Here is what I do in my template :

In my template, I am displaying class of an article like this (I would like the slug within the hyperlink class !) :

<?php foreach((get_the_category()) as $class) { 
echo '<a category="tag-cat ' . $category->slug . '" href="' . get_category_link($category->cat_ID) . '">' . $category->cat_name . '</a>'; } ?>

So, is there a option to solely show the direct (youngster) class ? And never the father or mother ?

Thanks upfront on your assist ! 🙂