2014-10-27 104 views
0

我試圖爲woocommerce類別使用自定義模板,但無法獲得有條件工作,我在這裏錯過了什麼嗎?我試着去改變條件標籤不工作,爲什麼?

<?php woocommerce_get_template_part('content', 'single-product-cans'); ?> 

要這樣:

<?php if (is_product_category('cans') { 
woocommerce_get_template_part('content', 'single-product-cans'); 
}else{ 
woocommerce_get_template_part('content', 'single-product'); 
} ?> 

這將引發此錯誤:語法錯誤,意外 '{'

回答

1

原因缺少一個更)(右括號)嘗試更換

if (is_product_category('cans') { 

to

if (is_product_category('cans')) { 

也儘量正確讀取錯誤,讓你的行號和描述你錯過了什麼

0

變化

if (is_product_category('cans') { 

if (is_product_category('cans')) {