I use the default Woocommerce widget "Filter by attribute" and I would like to prepend the name of each attributes.
But I don’t find any hook on it
Do you know how to achieve this ?
I use the default Woocommerce widget "Filter by attribute" and I would like to prepend the name of each attributes.
But I don’t find any hook on it
Do you know how to achieve this ?
2
Answers
I took a look at the source code and it seems that it’s only possible if you chose "List" as the "Display type". If so, then there is a filter applied to the displayed elements:
so in order to add custom filter, you can do:
Unfortunately, if you chose "Dropdown" as the "Display type", then there are no filters applied and it seems that you can’t modify labels. There’s only
used to display option labels, so the only way to change this is to change the value in the database.
What about extending its class to override the widget?
in your
functions.php
, add this class, you can then change the elements or do conditional statements depending on what you need.then in your
functions.php
again, unregister the default attribute widget and register the new one above: