我一直在努力寻找自定义分类法中按字母顺序排列的子术语的答案。。。我不建议更改核心WP文件,所以下面是我添加到分类中的内容。php文件列出自定义分类描述,并按字母顺序链接到子术语。修改以满足您的需要,我希望这对其他人有所帮助。
// Get Main Taxonomy for use in template file
$term = get_term_by( \'slug\', get_query_var( \'term\' ), get_query_var( \'taxonomy\' ) );
$termTaxonomy = $term->taxonomy;
<h1><?php echo apply_filters( \'the_title\', $term->name ); ?></h1>
<?php // test for description before unleashing a div
if ( !empty( $term->description ) ):
echo \'<div class="description">\';
echo $term->description;
echo \'</div>;
endif; ?>
// Now get children terms, using get_term & \'child_of\' get\'s us alphabetical order
$termchildren = get_terms( $termTaxonomy, array(
\'child_of\' => $term->term_id,
\'hierarchical\' => 0,
\'fields\' => \'ids\',
\'hide_empty\' => 0
) );
// Make an alphabetical linked list
echo \'<ul>\';
foreach ($termchildren as $child) {
$term = get_term_by( \'id\', $child, $termTaxonomy );
// Modify this echo to customize the output for each child term
echo \'<li><a href="\' . get_term_link( $term->name, $termTaxonomy ) . \'" alt="\' .$term->description. \'">\' . $term->name . \'</a></li>\';
}
echo \'</ul>\';