1 回答

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超16個(gè)贊
問題來自于您的代碼中的以下內(nèi)容:
$terms = wp_get_post_terms( $product->get_id(), $taxonomy, array('fields' => 'names') );
foreach ( $terms as $term_name )
$term_names['names'] = $term_name;
$out .= implode(', ', $term_names);
你可以用這個(gè)替換:
$terms = wp_get_post_terms( $product->get_id(), $taxonomy, array('fields' => 'names') );
$term_names = []; // Initializing
// Loop through each terms
foreach ( $terms as $term_name ) {
$term_names[] = $term_name;
}
$out .= implode(', ', $term_names);
或者用一行代碼就更好了:
$out .= $product->get_attribute( $taxonomy );
- 1 回答
- 0 關(guān)注
- 199 瀏覽
添加回答
舉報(bào)