WordPress: Show only the first category in “the_category”

To show only the first category that a post is listed in and not all of the categories, you simply need to add the following code to your theme template file:

<?php $category = get_the_category(); echo '<a class="category" href="'.get_category_link($category&#91;0&#93;->term_id ).'">'.$category[0]->cat_name.'</a>'; ?>
Free Graphics, Icons, Tutorials
Free Graphics Free Fitness Vector Icons Graphics PackFree Camping Vector Graphics PackFree Summer Graphics PackFree File Icon PackFree Fast Food Vector GraphicsFree Music Controls Vector Icon Pack
Sharing is caring...
Like & Follow
Share the love, share this page! Facebook Twitter Google Digg Reddit LinkedIn Pinterest Email
Close [X]
The Web Taylor
1000 Lakeside North Harbour Portsmouth, Hampshire PO6 3EN
02392 123358