Display custom post type categories as CSS class
-
Hi,
I want to display the categories of my custom post type as CSS class for the relevant post.
So this is my function:
function cats() { $terms = (get_the_ID(), 'event_cat'); foreach ( $terms as $term) { return $term->name; } }
And I include this in my list like this:
$output .= '<div class="'.cats().'">';
But now max one category is displayed per post. I guess because I return the function, instead of echoing it. But is there a way to return all categories that are attached to this post?
Guido
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Display custom post type categories as CSS class’ is closed to new replies.