【问题标题】:Show subcategories of a main category in "Shop By Category" section in Woocommerce Storefront在 Woocommerce Storefront 的“按类别购物”部分中显示主要类别的子类别
【发布时间】:2019-08-17 10:03:35
【问题描述】:

我正在使用店面主题设置 Woocommerce 商店,我想知道如何在“按类别购物”主页部分显示子类别而不是类别?

我需要显示产品子类别,因为我的根产品类别是一个独特的类别(“收藏”),其中包含所有主要子类别。

【问题讨论】:

  • Woocommerce 目录的设置不允许您这样做?有什么细节吗?可能是在这里回答:wordpress.stackexchange.com/questions/111992/…
  • 没有。我不能使用 Catalog 方法来做到这一点。我不知道我可以给你哪些细节...... :_(

标签: php wordpress woocommerce storefront taxonomy-terms


【解决方案1】:

实际上,您只能显示一个父类别术语 ID 的子类别,您的“收藏”产品类别就是这种情况:

add_filter( 'storefront_product_categories_args', 'custom_storefront_product_categories_args');
function custom_storefront_product_categories_args( $args ) {
    $args['columns'] = 4; // 4 columns
    $args['limit'] = 8;   // 8 items on 2 rows
    $args['child_categories'] = '18'; // <= The term ID of the main parent category

    return $args;
}

代码进入活动子主题(或活动主题)的 function.php 文件中。经过测试并且可以工作。


店面首页相关:Customize displayed products on Woocommerce Storefront home page

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    • 2020-01-06
    • 2018-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多