HUSKY - Product Filter for WooCommerce

woof_order_catalog

从 v.2.2.4/1.2.4

允许为目录添加自定义排序

参数

$catalog_data (array) — ['orderby' => string, 'order' => string, 'meta_key' => string]

源文件

index.php

代码示例


add_filter('woof_order_catalog', function($catalog_data) {
    // Force sorting by date descending for filtered results
    $catalog_data['orderby'] = 'date';
    $catalog_data['order'] = 'DESC';
    $catalog_data['meta_key'] = '';
    return $catalog_data;
});

使用说明

  • 将此代码添加到您的主题的 functions.php 文件或自定义插件中。
  • 此 hook 在过滤过程中应用 — 更改会立即生效。
  • 始终从回调函数返回预期的值类型。