HUSKY - Product Filter for WooCommerce

woof_template_part

Changes the template on the fly in the shortcode [woof_products]

 

Ab v.1.1.8/2.1.8

 

Parameter

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

Quelldatei

index.php

Codebeispiel


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

Verwendungshinweise

  • Fügen Sie diesen Code in die functions.php Datei Ihres Themes oder in ein benutzerdefiniertes Plugin ein.
  • Der Hook wird während des Filtervorgangs angewendet — Änderungen werden sofort wirksam.
  • Geben Sie stets den erwarteten Wertetyp aus der Callback-Funktion zurück.