The function you mention is going to return a list of links -- aren't you just trying to get the term slug as a class? Why not do.... $terms = get_the_terms($post->ID, 'my-category'); $slug_out = array(); foreach($terms as $term){ $slug_out[] = $term->slug; } echo '<div class="'.implode(', ', $slug_out).'">';