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 вашої теми або до власного плагіна.
  • Гак застосовується під час процесу фільтрації — зміни набувають чинності негайно.
  • Завжди повертайте очікуваний тип значення з функції зворотного виклику.