HUSKY - Product Filter for WooCommerce

woof_set_shortcode_taxonomyattr_behaviour

Este gancho funciona en index.php del complemento en public function woof_shortcode y manipula el atributo ‘additional_taxes‘.

Parámetros

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

Archivo fuente

index.php

Ejemplo de código


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

Notas de uso

  • Añade este código al archivo functions.php de tu tema o a un complemento personalizado.
  • El gancho se aplica durante el proceso de filtrado — los cambios surten efecto de inmediato.
  • Siempre devuelve el tipo de valor esperado desde la función de retorno.