Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce different template for products

I want to set different template for the relevant product category. I changed single-product.php file

   if (is_product_category( 'first-category' )) {
    woocommerce_get_template_part( 'content', 'single-product' );
}else{
    woocommerce_get_template_part( 'content', 'single-product-other' );
}

Still is loading content-single-product-other.php file content. I'm sure that the category of the product is checked

like image 797
Piotr Avatar asked Sep 16 '25 00:09

Piotr


1 Answers

it can happen if you have putted single-product-other.php in (yourtheme/woocommerce/) folder and single-product.php in plugin folder. All you have to do is put both template in your theme's woocommerce folder(it is the proper way to customize original code).

still if it does not work then try to replace your code

woocommerce_get_template_part( 'content', 'single-product' );

with this. wc_get_template_part( 'content', 'single-product' );

like image 57
Fawad Ali Avatar answered Sep 17 '25 15:09

Fawad Ali