HUSKY - Product Filter for WooCommerce

woof_template_part

ショートコード [woof_products] 内でテンプレートを動的に変更します。

 

バージョン 1.1.8/2.1.8 以降

 

パラメータ

$template (string) — the template name ('product' by default)

ソースファイル

index.php

コード例


add_filter('woof_template_part', function($template) {
    // Use a custom template for products display
    // Place your template at: wp-content/themes/your-theme/woof/product-custom.php
    $custom_template = 'product-custom';
    if (is_product_category('specials')) {
        return $custom_template;
    }
    return $template;
});

使用上の注意

  • このコードをテーマの functions.php ファイルまたはカスタムプラグインに追加してください。
  • フックはフィルタリング処理中に適用され、変更は即座に反映されます。
  • コールバック関数から常に期待される値の型を返してください。