What should be right template for the WooComerce  product page?

Problem: How to make that WooCommerce using single-product.php template, but single.php?

WooCommerce use single.php template instead single-product.php

Solution: This problem arose because we using custom WooCommerce template overrides in our theme and we need to declare WooCommerce support using the add_theme_support function. WooCommerce template overrides are only enabled on themes that declare WooCommerce support. If you do not declare WooCommerce support in your theme, WooCommerce will assume the theme is not designed for WooCommerce compatibility and will use shortcode-based unsupported theme rendering to display the shop.

Declaring WooCommerce support is straightforward and involves adding one function in your theme's functions.php file.

<?php
add_action( 'after_setup_theme', 'enable_woocommerce_support' );

function enable_woocommerce_support() {
	add_theme_support( 'woocommerce' );
}

Sources:

  1. https://wordpress.org/support/topic/single-product-is-using-single-php-not-single-product-php/
  2. https://github.com/woocommerce/woocommerce/wiki/Declaring-WooCommerce-support-in-themes#basic-usage

Leave Comment

4 Replies to “WooCommerce use single.php template instead single-product.php”

Your email address will not be published. Required fields are marked *