HUSKY - Product Filter for WooCommerce

woof_template_part

ショートコードでテンプレートをその場で変更できます [woof_products]

 

v.1.1.8/2.1.8 から

 

パラメーター

$template (string) — テンプレート名 ('product'がデフォルト)

ソースファイル

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ファイルまたはカスタムプラグインに追加してください。
  • このフックはフィルタリングプロセス中に適用され — 変更はすぐに有効になります。
  • 常にコールバック関数から期待される値の型を返してください。