如果要将术语描述添加为标题属性,并在悬停时显示,则可以“fork”get_the_term_list
函数添加到将添加title属性的版本,类似这样的操作应该可以:
function get_terms_with_desc( $id = 0 , $taxonomy = \'post_tag\', $before = \'\', $sep = \'\', $after = \'\' ){
$terms = get_the_terms( $id, $taxonomy );
if ( is_wp_error( $terms ) )
return $terms;
if ( empty( $terms ) )
return false;
foreach ( $terms as $term ) {
$link = get_term_link( $term, $taxonomy );
if ( is_wp_error( $link ) )
return $link;
$term_links[] = \'<a href="\' . esc_url( $link ) . \'" rel="tag" title="\'.esc_attr( $term->description ).\'">\' . $term->name . \'</a>\';
}
$term_links = apply_filters( "term_links-$taxonomy", $term_links );
return $before . join( $sep, $term_links ) . $after;
}