0
返回产品属性在Woocommerce 2.4,我编辑/loop/title.php以包括产品属性,像这样:Woocommerce - 在function.php
<h3 itemprop="name" class="product_title entry-title"><?php $versionvalues get_the_terms($product->id, 'pa_artist');
foreach ($versionvalues as $versionvalue) {
echo $versionvalue->name;
} ?></h3>
在Woocommerce 2.5,title.php不再用过的。它被构建成一个功能。我真的很难通过在我的子主题中编辑我的functions.php来返回产品属性。
我一直在尝试使用此代码,但foreach
总是会引发错误。
if ( ! function_exists('woocommerce_template_loop_product_title')) {
/**
* Show the product title in the product loop. By default this is an H3.
*/
function woocommerce_template_loop_product_title() {
echo '<h3>' . get_the_title() . '</h3>';
echo '<h3 itemprop="name" class="product_title entry-title">' . $versionvalues get_the_terms($product->id, 'pa_artist');
echo foreach ($versionvalues as $versionvalue) {
echo $versionvalue->name;
echo } '</h3>';
}
}
有人指着我正确的方向吗?
这个效果很好,但它将pa_artist添加到开头。在我添加之前,它显示标题和价格,现在它显示pa_artist,标题和价格。我想显示标题,pa_artist,然后价格。 – mwiggs
尝试更改10到11 ... – Reigel
就是这样!谢谢!!!!! 1 – mwiggs