可以使用两个函数构建列表:get_terms()
和get_term_link()
:
<?php
function wpse73271_get_term_archive_link_list( $taxonomy ) {
// First, get an array of term IDs
$term_objects = get_terms( $taxonomy );
// Now, loop through $term_ids and get
// an array of term archive permalinks
foreach ( $term_objects as $term_object ) {
$term_object->url = get_term_link( $term_object, $taxonomy );
$term_object->permalink = \'<a href="\' . $term_object->url . \'">\' . $term_object->name . \'</a>\';
}
// Now, build an HTML list of permalinks:
$output = \'<ul>\';
foreach ( $term_objects as $term_object ) {
$output .= \'<li>\' . $term_object->permalink . \'</li>\';
}
$output .= \'</ul>\';
// Now return the output
return $output;
}
?>