您需要自己对其进行排序:
$terms = get_the_terms( $post->ID, \'category\');
foreach ( $terms as $term ) {
$newterms[$term->slug] = $term;
}
ksort($newterms);
foreach ( $newterms as $term ) {
echo "<li>" .$term->name. "</li>";
}
或者,如果你喜欢冒险,也可以使用过滤器:
function alpha_sort_terms($terms) {
remove_filter(\'get_the_terms\',\'alpha_sort_terms\');
foreach ( $terms as $term ) {
$newterms[$term->slug] = $term;
}
ksort($newterms);
return $newterms;
}
add_filter(\'get_the_terms\',\'alpha_sort_terms\');
$terms = get_the_terms( $post->ID, \'category\');
foreach ( $terms as $term ) {
echo "<li>" .$term->name. "</li>";
}