I am trying to output all terms attached to a specific post (including custom taxonomy terms) as CSS classes applied to a DIV
Something like that :
<div <?php post_class('class-name'); ?>></div>
So it outputs something like this :
<div class="class-name term1 term2 term3 term4"></div>
How do I do this?
Thanks!
The easiest and most straight-forward way to do this would be:
You could also apply a filter to
post_class
that does essentially the same.I am sure you want more complicated logic though– for example, restrict this only to certain post types perhaps.