2010-07-10 22 views
0

我有一個自定義分類法,它需要爲每個術語應用不同的顏色。我想我可以抓住分類的slu and,並把它放在課堂上。不幸的是,我一直嘗試着失敗。我已經嘗試了幾件事情,但無濟於事。作爲HTML類的自定義分類法

的想什麼,我

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

回答

0

首先你需要通過運用術語作爲類的蛞蝓每學期獲得定製taxomomy和循環樣品。

<?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>'; 
?> 
+0

是的,這將給我一個清單,但我需要什麼我需要它只是將類添加到一個術語。每篇文章只有一個項目。我最終修改了post_class()並通過了CSS。 – curtismchale 2010-07-27 03:09:18

相關問題