【发布时间】:2018-05-18 15:54:56
【问题描述】:
我目前在 WooCommerce 网上商店工作。我选择了按类别购物选项,并且首页当前显示前 3 个类别。
我希望它显示 3 个随机类别,而不是前三个类别。
我能够将自定义函数添加到我的 function.php(代码如下)以增加列出的类别数量(至 10 个),但我无法让类别以随机顺序显示。
add_filter('storefront_product_categories_shortcode_args','custom_storefront_category_per_page' );
// Category Products
function custom_storefront_category_per_page( $args ) {
$args['number'] = 10;
return $args;
}
我已经厌倦了设置 $args['orderby'] = "rand";没有运气。我猜这仅适用于产品。我应该更改什么功能以使首页上的“按类别购物”部分列出 3 个随机类别,而不是按 AESC 或 DESC 顺序排列的 3 个类别?
【问题讨论】:
标签: php wordpress random woocommerce hook