dounai6626 2018-02-08 11:17
浏览 55
已采纳

更新3.3.0 / 3.3.1后,Woocommerce archive-product.php模板功能中断

I've been using the code below for a number of years with no problems what so ever until I upgraded to Woocommerce version 3.1.1.

The function simply changes the default archive-product.php to an alternative template based on the defined Woocommerce category slug.

I've read through the change logs and there are a few things I think that may be connected to my problem but I'm not sure, hence why I'm reaching out here :)

The relevant note from the changelog to me seemed to be:

Fix – Added woocommerce_output_product_categories to replace woocommerce_product_subcategories function to prevent outdated theme template files from outputting categories on the shop and category pages in err.

However, there were many changes made to the default layout/theme of Woocommerce in the previous version 3.3.0 which may also be at fault.

Any help or guidance on this one would be awesome.

add_filter( 'template_include', 'wpse138858_woocommerce_category_archive_template' );

function wpse138858_woocommerce_category_archive_template( $original_template ) {

    if ( is_product_category( array( 'cat-1', 'cat-2' ) ) )
    {
        return get_stylesheet_directory().'/woocommerce/archive-product_no_sidebar.php';
    }
    elseif ( is_product_category( array( 'cat-3', 'cat-4' ) ) )
    {
        return get_stylesheet_directory().'/woocommerce/archive-product_sidebar.php';
    } 
    elseif ( is_product_category( array( 'cat-5', 'cat-6' ) ) )
    {
        return get_stylesheet_directory().'/woocommerce/archive-product_clubs_page.php';
    } 
    else 
    {
        return $original_template;
    }
}

EDIT - There were errors in the function that shouldn't have been there, my fault, sorry... I have copied the code straight from the live site and just cut the category down so its more readable

  • 写回答

2条回答 默认 最新

  • dsxon40042 2018-02-18 23:25
    关注

    Install plugin WP Rollback and then click rollback in the installed plugins menu on woocommerce. Had to do the same.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值