HUSKY - Product Filter for WooCommerce

woof_template_part

Zmienia szablon na bieżąco w shortcodzie [woof_products]

 

Od wersji 1.1.8/2.1.8

 

Parametry

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

Plik źródłowy

index.php

Przykład kodu


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;
});

Uwagi dotyczące stosowania

  • Dodaj ten kod do pliku functions.php swojego motywu lub własnej wtyczki.
  • Hook jest stosowany podczas procesu filtrowania — zmiany są uwzględniane natychmiast.
  • Zawsze zwracaj oczekiwany typ wartości z funkcji zwrotnej.