HUSKY - Product Filter for WooCommerce

woof_set_shortcode_taxonomyattr_behaviour

Ten hook działa w pliku index.php wtyczki w publicznej funkcji woof_shortcode i manipuluje atrybutem 'additional_taxes'.

Parametry

$taxonomies_string (string) — the taxonomies string from the shortcode attribute

Plik źródłowy

index.php

Przykład kodu


add_filter('woof_set_shortcode_taxonomyattr_behaviour', function($taxonomies_string) {
    // Force specific taxonomy to always be included
    $additional = 'product_tag:featured,on_sale';
    if (!empty($taxonomies_string)) {
        $taxonomies_string .= '+' . $additional;
    } else {
        $taxonomies_string = $additional;
    }
    return $taxonomies_string;
});

Uwagi dotyczące użycia

  • Dodaj ten kod do pliku functions.php swojego motywu lub niestandardowej wtyczki.
  • Hook jest stosowany podczas procesu filtrowania – zmiany są widoczne natychmiast.
  • Zawsze zwracaj oczekiwany typ wartości z funkcji zwrotnej.