woof-set-shortcode-taxonomyattr-behaviour
woof_set_shortcode_taxonomyattr_behaviour
Permet de modifier le comportement de l'attribut taxonomies dans le shortcode [woof_products] et [woof_products_ids_prediction].
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.phpde 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.