WooCommerce店面不包括主页上的类别



在店面主页模板上显示 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' );

店面主页模板使用 woocommerce"product_categories"短代码。这有一组有限的参数,其中一些的命名有点不寻常。没有排除参数。您可以使用"ids"参数而不是"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' );

最新更新