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


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

    <?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困扰了两天才得到的教训,希望有遇到相同问题的朋友借鉴。

  • 相关阅读:
    ReentrantLock重入锁
    Java对象序列化和反序列
    echarts踩坑笔记
    金融风控之贷款违约预测笔记
    go安装模块
    vasp计算轨道吸附
    html
    css/js 小技巧
    python 调用父类方法:super && 直接使用父类名
    python 多线程
  • 原文地址:https://www.cnblogs.com/ytkah/p/12341826.html
Copyright © 2020-2023  润新知