1 回答
TA贡献1801条经验 获得超15个赞
问题来自于您的代码中的以下内容:
$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 关注
- 147 浏览
添加回答
举报