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

Php 条件标记不起作用,为什么?,php,wordpress,woocommerce,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-can

我正在尝试为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' );
} ?>

导致又缺少一个
(右括号)尝试替换

if (is_product_category( 'cans' ) {
if (is_product_category( 'cans' ) {
if (is_product_category( 'cans' )) {

另外,请尝试正确读取错误信息,该错误信息会给出您缺少的行号和描述

if (is_product_category( 'cans' )) {