HUSKY - Product Filter for WooCommerce

woof_draw_products_html

[woof_products] shortcode 的渲染 HTML 作为 woof_draw_products 中的 AJAX 响应的一部分返回之前对其进行过滤。使用此过滤器在 shortcode 生成产品列表 HTML 后对其进行包装、转换或修改。

参数

$html (string) — 来自 do_shortcode() 的渲染 HTML。

$shortcode_str (string) — 已执行的完整 shortcode 字符串。

源文件

index.php, line 2741

代码示例


add_filter("woof_draw_products_html", function ($html, $shortcode_str) {
    // Add a wrapper div around the products
    return "<div class=\"woof-custom-wrapper\">" . $html . "</div>";
}, 10, 2);

使用说明

  • 将此代码添加到您主题的 functions.php 文件或自定义插件中。
  • 此钩子仅在通过 woof_draw_products 处理程序进行 AJAX 请求时触发。
  • 接受 2 个参数 — 请记住在您的函数签名中声明 $a, $b