Custom taxonomy as HTML class

Custom taxonomy as HTML class

I have a custom taxonomy that needs a different colour applied to each term inside. I figured I could grab the slug of the taxonomy and put it in a class. Unfortunately I've been defeated with every try. I've tried a few things with get terms to no avail.

Sample of what I'd like

<div class="<?php echo $myCustomClass; ?>">the custom taxonomy</div> 

Wordpress Email subscribtion?


tinymce wordpress copy and paste losing http:// prefix
First you would need to get the custom taxomomy and loop through every term applying the slug of the term as the class..
More than 1 widget in wordpress
<?php   // get the tags from your custom taxonomy, in this case it's 'skills'   $tags = get_terms('skills');    // print out the start of the list, putting an ID on it to make styling it easier   echo '<ul id="taxonomy-list-skills">';   // loop through each tag as a list item   foreach($tags as $tag)   {      echo '<li class="'.$tag->slug.'">'.$tag->name.'</li>';   }   // close the list   echo  '</ul>'; ?>  

add a page to sidebar

85 out of 100 based on 55 user ratings 955 reviews