DescriptionDescription
This filter is called after facet choices are queried (filter facets).
It allows to modify the choice arguments used to render facet content.
ArgumentsArguments
Argument | Type | Description |
$choices | array | Holds facet choices |
$facet | array | Holds facet settings |
ExampleExample
PHP
functions.php
function prefix_facet_choices( $choices, $facet ) {
// If it does not matches facet id 1.
if ( 1 !== $facet['id'] ) {
return $choices;
}
return array_map(
function( $choice ) {
switch ( $choice->facet_value ) {
case 'pants':
$choice->facet_name = '👖 Pants';
break;
case 'dresses':
$choice->facet_name = '👗 Dresses';
break;
case 'shirts':
$choice->facet_name = '👕 Shirts';
break;
case 'socks':
$choice->facet_name = '🧦 Socks';
}
return $choice;
},
$choices
);
}
add_filter( 'wp_grid_builder/facet/choices', 'prefix_facet_choices', 10, 2 );