<?php
$categories = get_the_category();
if($categories){
echo '<div>';
foreach($categories as $category) {
echo '<span>' . $category->cat_name . '</span>';
}
echo '</div>';
}
?>
If you need just parent cagetory
<?php
$perma_cat = get_post_meta($post->ID , '_category_permalink', true);
if ( $perma_cat != null ) {
$cat_id = $perma_cat['category'];
$category = get_category($cat_id);
} else {
$categories = get_the_category();
$category = $categories[0];
}
$category_link = get_category_link($category);
$category_name = $category->name;
?>
<a href="<?php echo $category_link ?>"><?php echo $category_name ?></a>