问题描述
我正在尝试自定义标准的 woocommerce 主题,到目前为止效果很好.我将所有模板文件从 /plugins/woocommerce/templates
复制到 /mytheme/woocommerce
并自定义文件.
I'm trying to customize the standard woocommerce theme and so far that has worked well. I copied all template files from /plugins/woocommerce/templates
to /mytheme/woocommerce
and customized the files.
但是当我在 archive-product.php
中更改某些内容时,没有任何反应?我什至尝试在核心文件 (/plugins/woocommerce/templates/archive-product.php
) 中自定义它,但我不起作用.
But when i'm change something in archive-product.php
nothing happens? I even tried to customize this in the core files (/plugins/woocommerce/templates/archive-product.php
) but i doesn't work.
我想更改 h1
标题的类:<h1 class="page-title"><?php woocommerce_page_title();?></h1>
.
I want to change the class of the h1
heading: <h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
.
所以我查找了所有 woocommerce 模板文件,page-title
类只出现在这个文件中(以防止编辑错误的文件).
So i looked up all woocommerce template files, the class page-title
occurs only in this one file (to prevent editing the wrong file).
详细来说,我想自定义这个路径中使用的主题:http://example.com/product-category/mycategory
In detail, i want to customize the theme used in this path: http://example.com/product-category/mycategory
推荐答案
似乎这仍然是 Woocommerce 中的一个问题.对于登陆这里的任何人,从 2.1.6 版开始,以下解决方案对我有用.
Seems this is STILL an issue in Woocommerce. For anyone landing here, the following solution was working for me as of version 2.1.6.
显然问题是由于函数 woocommerce_content() 输出了错误的存档内容页面.
Apparently the problem is due to the function woocommerce_content() outputting the wrong page for archive content.
我使用以下方法来解决它:
I used the following to get around it:
将 woocommerce.php 中的 woocommerce_content() 替换为:
replace woocommerce_content() in woocommerce.php with:
if ( is_singular( 'product' ) ) {
woocommerce_content();
}else{
//For ANY product archive.
//Product taxonomy, product search or /shop landing
woocommerce_get_template( 'archive-product.php' );
}
信用:在此处
这篇关于对 archive-product.php 的更改不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!