HUSKY - Product Filter for WooCommerce

woof_set_shortcode_taxonomyattr_behaviour

Ce hook fonctionne dans index.php du plugin dans public function woof_shortcode et permet de manipuler avec ‘taxes_additionnelles».

Paramètres

$taxonomies_string (string) — chaîne de caractères avec les taxonomies de l'attribut du shortcode

Fichier source

index.php

Exemple de code


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

Notes d'utilisation

  • Ajoutez ce code au fichier functions.php de votre thème ou à un plugin personnalisé.
  • Le hook est appliqué pendant le processus de filtrage — les modifications prennent effet immédiatement.
  • Retournez toujours le type de valeur attendu depuis la fonction de rappel.