WordPress display only child category in template
If you know the parent category name, then you could just do an if inside the foreach Demo code <?php foreach((get_the_category()) as $category) { if($category->cat_name!=”parent category name”) { echo ‘<a class=”tag-cat ‘ . $category->slug . ‘” href=”‘ . get_category_link($category->cat_ID) . ‘”>’ . $category->cat_name . ‘</a>’; } } ?> ?>