条件标签不起作用,为什么?

时间:2014-10-27 12:30:36

标签: php wordpress woocommerce

我试图将自定义模板用于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' );
} ?>

这会抛出此错误:语法错误,意外的'{'

2 个答案:

答案 0 :(得分:1)

导致错过一个)(右括号)尝试替换

if (is_product_category( 'cans' ) {

if (is_product_category( 'cans' )) {

同时尝试正确读取错误,为您提供缺少的行号和说明

答案 1 :(得分:0)

更改

if (is_product_category( 'cans' ) {

if (is_product_category( 'cans' )) {
相关问题