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, 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 を宣言することを忘れないでください。