Get Wordpress Category from Single Post
How about get_the_category?
You can then do
$category = get_the_category();$firstCategory = $category[0]->cat_name;
For the lazy and the learning, to put it into your theme, Rfvgyhn's full code
<?php $category = get_the_category();$firstCategory = $category[0]->cat_name; echo $firstCategory;?>
<div class="post_category"> <?php $category = get_the_category(); $allcategory = get_the_category(); foreach ($allcategory as $category) { ?> <a class="btn"><?php echo $category->cat_name;; ?></a> <?php } ?> </div>