2014-10-27 59 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')) {