1 回答
TA贡献1795条经验 获得超7个赞
添加以下代码片段以完成您的任务 -
add_action( 'woocommerce_after_shop_loop_item', 'list_author_terms', 6 );
function list_author_terms(){
$taxonomies = array( 'authors', 'artists', 'illustrators' );
$pro_list_terms = array();
foreach ( $taxonomies as $taxonomy ) {
$term_obj_list = get_the_terms( get_the_ID(), $taxonomy );
$tax_obj = get_taxonomy( $taxonomy );
if( $term_obj_list && ! is_wp_error( $term_obj_list ) ){
foreach ( $term_obj_list as $term ) {
$link = get_term_link( $term, $taxonomy );
$pro_list_terms[] = '<a href="' . esc_url( $link ) . '" class="author rsc-tp">' . $term->name . ' (' .$tax_obj->labels->singular_name . ')</a>';
}
}
}
echo join( ', ', $pro_list_terms );
}
- 1 回答
- 0 关注
- 153 浏览
添加回答
举报