如何在woocommerce中为不同类别的存档页面调用不同的模板 [英] How to call different template for different category archive page in woocommerce

查看:30
本文介绍了如何在woocommerce中为不同类别的存档页面调用不同的模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在woocommerce中有两个类别,一个是Men",另一个是Women".

I have two categories in woocommerce One is "Men" and Other is "Women".

默认 woocommerce 调用 archive-product.php 用于类别存档页面.

Be default woocommerce call archive-product.php for category archive page.

但我想为每个类别存档页面显示不同的布局.

But I want to show different layout for each category archive page.

如何做到这一点?

推荐答案

您可以看到 WooCommerce 如何过滤 template_include 并会按照以下顺序自动查找分类模板

You can see how WooCommerce is filtering template_include and will automatically look for taxonomy templates in the following order

taxonomy-YOUR_TAXONOMY-YOUR_TERM.php

然后

taxonomy-YOUR_TAXONOMY.php

因此,在您的示例中,我相信您会创建以下模板:

So in your example I believe you would create the following templates:

taxonomy-product_cat-men.php

taxonomy-product_cat-women.php

这篇关于如何在woocommerce中为不同类别的存档页面调用不同的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆