对 archive

编程入门 行业动态 更新时间:2024-10-21 03:30:55
本文介绍了对 archive-product.php 的更改不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试自定义标准的 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/product-category/mycategory

In detail, i want to customize the theme used in this path: http://example/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 的更改不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 06:42:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1080249.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:archive

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!