我使用Wordpress,並在woocommerce中設置了一個商店。我試圖在產品頁面上顯示品牌名稱作爲鏈接,並且我在代碼方面遇到困難。到目前爲止,我有:顯示變量作爲鏈接
<?php $brands = wp_get_post_terms($post->ID, 'product_brand', array("fields" => "all"));
echo "Brend: ";
foreach($brands as $brand) {
$url = get_term_link($brand->slug, 'product_brand');
echo '<a href="' . $url . $brand->name '"></a>';
}?>
我得到以下錯誤:
Parse error: syntax error, unexpected ''">'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in your code on line 6
我沒能看到我在做什麼錯。任何幫助將不勝感激。
回聲'; –
'echo'';'用這個 – devpro