/facet/choices

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

ArgumentTypeDescription
$choices arrayHolds facet choices
$facetarrayHolds facet settings

ExampleExample

PHP
functions.php
function prefix_facet_choices( $choices, $facet ) {

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