zoukankan      html  css  js  c++  java
  • 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困扰了两天才得到的教训,希望有遇到相同问题的朋友借鉴。

  • 相关阅读:
    ZOJ4125 Sekiro
    ZOJ4118 Stones in the Bucket
    ZOJ4115 Wandering Robot
    ZOJ4113 Calandar
    【递归】N皇后问题 和 2n皇后问题 dfs
    7-18
    7_13
    二维前缀和
    64位整数乘法
    【分治】魔法石的诱惑
  • 原文地址:https://www.cnblogs.com/ytkah/p/12341826.html
Copyright © 2011-2022 走看看