<?php echo get_the_term_list($post->ID, TAXONOMY_NAME, ' ', ', ', ''); ?>
上面的代码当前生成自定义类别的名称。大多数时候这都很好。但是在一个位置,我想有一个自定义的"href",显示"查看更多"而不是显示类别的名称。
想法?
我认为您想使用"get_the_terms",然后使用"get_term_link"而不是包含html的"get_the_term_list"。
所以你可以做到
$terms = get_the_terms( $post->ID, $taxonomy );
foreach($terms as $term){
echo "<a href=". get_term_link( $term->term_id, $taxonomy ). ">CUSTOM LABEL</a>";
}
get_the_terms文档 -> http://codex.wordpress.org/Function_Reference/get_the_termsget_term_link文档 -> http://codex.wordpress.org/Function_Reference/get_term_link