1

在店面主页模板上显示 3 个类别。我可以改变一些方面,例如隐藏空白和订单。我想要做的是包括或排除特定类别,可能是通过他们的 id。

function my_edit_storefront_category( $args ) {
    $args['number'] = 10; // works
    $args['exclude'] = "11,22,33"; // doesn't work
    $args['include'] = array(11,22,33); // doesn't work either
    return $args;
}
add_filter('storefront_product_categories_shortcode_args','my_edit_storefront_category' );
4

1 回答 1

2

店面主页模板使用 woocommerce 'product_categories' 短代码。这有一组有限的参数,其中一些命名有点不寻常。没有排除 arg。您可以使用 'ids' arg 而不是 'include' 通过 id 包含类别。

function test_storefront_category_filtering( $args ) {
    $args['ids'] = '56,23,26';
    return $args;
}
add_filter('storefront_product_categories_shortcode_args','test_storefront_category_filtering' );
于 2018-03-19T10:27:28.880 回答