前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >woocommerce的taxonomy-product_cat分类模板也需要定义否则可能排版乱了

woocommerce的taxonomy-product_cat分类模板也需要定义否则可能排版乱了

作者头像
ytkah
发布2020-02-25 14:19:12
7750
发布2020-02-25 14:19:12
举报
文章被收录于专栏:ytkahytkah

  我们知道woocommerce(下称wc)的archive-product.php模板是定义shop page的,可能比较比较早版本的wc也是用这个文件来定义分类的,但是如果你升级到最新版本的wc会有一个单独的taxonomy-product_cat.php来定义产品分类模板,虽然是通过代码调用archive-product.php,

代码语言:javascript
复制
<?php
/**
 * The Template for displaying products in a product category. Simply includes the archive template
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/taxonomy-product_cat.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see 	    https://docs.woocommerce.com/document/template-structure/
 * @package 	WooCommerce/Templates
 * @version     1.6.4
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

wc_get_template( 'archive-product.php' );

  但一定要重新定义这个文件,特别是使用了独立pc和mobile模板,你可以复制一份archive-product.php然后重命名成taxonomy-product_cat.php,这样打开手机端的产品分类就不会出现页面错乱了。这是ytkah困扰了两天才得到的教训,希望有遇到相同问题的朋友借鉴。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-02-21 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档