【发布时间】:2019-07-08 18:35:12
【问题描述】:
我在主页上显示类别列表。我需要最后一个类别排在第二位。我研究了排序选项,但它们不适合。 按名称,按 ID,随机。 ID 为“50”的Сategory 需要排在列表的第二位。
add_filter( 'storefront_product_categories_args', 'custom_storefront_product_categories');
function custom_storefront_product_categories( $args ) {
$args['limit'] = 9;
$args['columns'] = 3;
$args['orderby'] = 'id'; // sort by id category
return $args;
}
编辑:
我尝试使用以下方式添加产品类别排序 ID:
function custom_storefront_category_filtering( $args ) {
$args['ids'] = '16,50,17,18,19,20,21,22,23'; // need such a sequence of categories
return $args;
}
add_filter('storefront_product_categories_shortcode_args','custom_storefront_category_filtering' );
但它只包括产品类别。
【问题讨论】:
-
你能改写你的问题吗?您想如何在基于 Storefront 主题的网站的主页上重新排序类别?
ids是什么? -
@KashifRafique,我想添加自定义排序顺序。标准不允许按正确的顺序排序
标签: php wordpress sorting woocommerce custom-taxonomy