在Woocommerce Storefront的“按类别购物”部分中显示主要类别的子类别

问题描述 投票:2回答:1

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

我需要显示产品子类别,因为我的根产品类别是唯一的(“收集”),并且在其中我拥有所有主要子类别。

我的网站是:www.thomassi.com

php wordpress woocommerce storefront taxonomy-terms
1个回答
0
投票

实际上,您只能显示一个父类别术语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

© www.soinside.com 2019 - 2024. All rights reserved.