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 關注
- 177 瀏覽
添加回答
舉報