admin管理员组文章数量:1277887
I´m making my first Woocommerce theme.
In the documentation and in plugins/woocommerce/templates/single-product.php
, it´s written :
This template can be overridden by copying it to yourtheme/woocommerce/single-product.php
But when I do this, it does not work and if I put the file on my theme root, it got it, why ?
Comments inside files and WooCommerce documentation are not updated ?
I´m making my first Woocommerce theme.
In the documentation and in plugins/woocommerce/templates/single-product.php
, it´s written :
This template can be overridden by copying it to yourtheme/woocommerce/single-product.php
But when I do this, it does not work and if I put the file on my theme root, it got it, why ?
Comments inside files and WooCommerce documentation are not updated ?
Share Improve this question asked Oct 23, 2019 at 16:56 J.BizMaiJ.BizMai 9002 gold badges10 silver badges30 bronze badges 3 |2 Answers
Reset to default 1As @ChetanVaghela said in comments, to use the woocommerce structure you need to add this code line :
add_theme_support( 'woocommerce' );
Sally in the comments above gave a very informative answer to this question, which answers the OP.
I would like to quote it again:
single-product.php
in the root theme folder works because that is a valid/recognized template for single posts of the product type - i.e.single-<post type>.php
- and by default, it has a higher priority and would be used even if your theme does havewoocommerce/single-product.php
Also Chetan mentioned to add theme support with
add_theme_support( 'woocommerce' );
But note, if at woocommerce.php
file resides a your your theme's root folder, the single-product.php
and archive-product.php
wont work.
WooCommerce plugin comes with a handy checking tool at your Dashboard. Go the WooCommerce -> Status
- And it reports if your theme has been modified to add wocommerce support or not.
- Any flags to notice
- And at the last section it shows the list of template files which are overwritten and if there are issues regarding them. For example, if your theme has a
woocommerce.php
it would notify you it too!
本文标签: theme developmentwhy mythemesingleproductphp works but not mythemewoocommercesingleproductphp
版权声明:本文标题:theme development - why mythemesingle-product.php works but not mythemewoocommercesingle-product.php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741286466a2370298.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
single-product.php
in the root theme folder works because that is a valid/recognized template for single posts of theproduct
type - i.e.single-<post type>.php
- and by default, it has a higher priority and would be used even if your theme does havewoocommerce/single-product.php
. – Sally CJ Commented Oct 23, 2019 at 18:37