Jerry
Jerry

Reputation: 1089

Conditional tags not working, why?

Im trying to use a custom template for a woocommerce category, but can't get the conditional to work, do I miss something here? Im trying to change

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

To this:

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

This throws this error: syntax error, unexpected '{'

Upvotes: 0

Views: 686

Answers (2)

Ram Sharma
Ram Sharma

Reputation: 8809

change

if (is_product_category( 'cans' ) {

to

if (is_product_category( 'cans' )) {

Upvotes: 0

Rakesh Sharma
Rakesh Sharma

Reputation: 13728

cause missing one more )(closing parenthesis) try to replace

if (is_product_category( 'cans' ) {

to

if (is_product_category( 'cans' )) {

Also try to read error properly which gives you line number and description what you missing

Upvotes: 1

Related Questions