HUSKY - Product Filter for WooCommerce

woof_draw_products_html

[woof_products] ショートコードのレンダリングHTMLが woof_draw_products のAJAXレスポンスの一部として返される前にフィルタリングします。このフィルターを使用して、ショートコードによって生成された商品一覧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 を宣言することを忘れないでください。