Get a list of commas separated categories inside a loop

I want to get the list of categories of a post inside the loop. Normally, I would use

the_category(', ');

But this does output a link, and I only want the category name.
Any ideas?

3 Answers
3

Should be easy enough i think..

<?php 
foreach((get_the_category()) as $category) { 
    //this would print cat names.. You can arrange in list or whatever you want..
    echo '<span>'.$category->cat_name .'</span>';
} 
?>

.
Hope This Helps 😉

Leave a Comment