How do you echo a category name?
-
I’ve researched a lot about doing this, and I was only able to figure out how to put all of the categories into an array.
I have this currently:
$category = get_the_category();
echo $category[0]->cat_name;Then I guess I can just change 0 to 1, 2, 3, etc, to get the different categories. But what if I just want to echo the current category for that page? (from outside the loop if that’s possible).
Any suggestions?
Edit: P.S. I’ve also been trying other stuff like the_category(‘, ‘); but they they seem to echo a category link or the path to the category.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How do you echo a category name?’ is closed to new replies.