1 回答

TA貢獻1801條經驗 獲得超16個贊
問題來自于您的代碼中的以下內容:
$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);
你可以用這個替換:
$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 關注
- 186 瀏覽
添加回答
舉報