因此,我必须显示自定义帖子中的分类法及其术语。
我有一些分类法(大约10个),它们都有一些术语。每个帖子可以有任意数量的分类法,但所有这些分类法都只能选择一个术语。
我需要显示文章中出现的术语列表,并需要显示自定义名称来代替分类名称。
例如:分类法:BikesTerm:BTT
我需要显示“Bicycle:BTT”之类的内容,而不是显示“Bicycle:BTT”之类的内容。
我有一段代码给了我分类法和术语,但想不出最好的方法来“更改”自定义名称的分类法。
以下是迄今为止的代码:
//creates the array to format the list of taxonomies
$args = array(
\'template\' => __( \'%s: %l.\' ),
\'term_template\' => \'<a href="%1$s">%2$s</a>\',
);
//creates the array to receive all the taxonomies
$taxList = get_the_taxonomies( $post->ID, $args );
//shows every taxonomy separately
foreach ($taxList as $taxItem) {
echo $taxItem;
endforeach;