//分类代码:
register_taxonomy( 'product_size', 'product', array(
'labels' => array(
'name' => 'Size',
'add_new' => 'Add Product Size',
'add_new_item' => 'Add Product Size',
),
'public' => true,
'hierarchical' => true,
));
//在此处显示代码:
<li>
<span>Sizes:</span>
<?php
$sizes = get_the_terms( get_the_ID(), 'product_size' );
$names = array();
foreach ($sizes as $size) :
$names[] = $size->name;
endforeach;
echo implode( ', ', $name);
?>
</li>
但不起作用,并显示消息:
警告:在第153行的C:\ xampp \ htdocs \ global \ wp-content \ themes \ newcomet \ inc \ customoze \ customoze-woocommerce.php中为foreach()提供的参数无效
怎么能解决这个问题?请帮帮我。