stuckinamiddle
stuckinamiddle

Reputation: 121

Wordpress: Display only category name within The Loop

I want to display only the category name within The Loop, without link, markup or anything else. This:

<?php the_category(); ?>

only gets me the category name as a list object with a link.

Upvotes: 0

Views: 198

Answers (1)

jurruh
jurruh

Reputation: 119

This will work:

$category = get_the_category();
echo $category[0]->cat_name;

Upvotes: 1

Related Questions