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!
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!
Share Improve this question edited Nov 20, 2020 at 13:23 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Nov 20, 2020 at 12:36 Laurence ReevesLaurence Reeves 11 Answer
Reset to default 1The 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' );