woof_draw_products_html
在 woof_draw_products 的 AJAX 响应中返回之前,过滤 [woof_products] 短代码渲染的 HTML。使用此过滤器,可在短代码生成产品列表 HTML 后对其进行包装、转换或修改。
参数
$html (string) — 来自 do_shortcode() 的渲染 HTML。
$shortcode_str (string) — 已执行的完整短代码字符串。
源文件
index.php,第 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。