0

I found the solution here WooCommerce: Change template for single product page

But, it doesn't actually explain how to do it.. or i'm just not understanding enough. I did give it a go and placed that text in the "single-product.php", changing where it says dirname to/products.php (my template file name), but nothing changed.

When I go to the product page, I want to be able to use that drop down box that should appear on the right of the page to change the default template as the style on the product page is incorrect.

Can someone please dumb this down for me? I'm pulling my hair out as that's the only thing left to do on my website, I can then make it live.

Thanks!

1 Answer 1

1

The dropdown box that you are talking about is for custom WordPress template that WordPress supports by default.

In order to override woocomerce template e.g. single-product.php what you have to do is to create a folder with name woocommerce inside your theme folder e.g.

/wp-content/themes/{your_theme_name}/woocommerce/

and copy the file from /wp-content/plugins/woocommerce/templates/single-product.php into your theme's woocommerce directory e.g.

/wp-content/themes/{your_theme_name}/woocommerce/single-product.php

Now its properly override and you can make changes in single-product.php within your theme.

This way your changes will remain intact even if you update woocommerce plugin.

To know in detail about woocomerce template overriding see this link

Edit:

Declaring WooCommerce support in themes

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

function mytheme_add_woocommerce_support() {
    add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
3
  • Thank you. I've done as you've advised but it still doesn't seem to work? Nov 20, 2020 at 14:30
  • 1
    Did you add_theme_support too?
    – Rup
    Nov 20, 2020 at 16:42
  • @LaurenceReeves Yes, do check if you have added the WooCommerce support for your theme. I have update my answer.
    – Awais
    Nov 22, 2020 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.