facetwp change a numeric value to a label

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

/**
* reindex after adding or updating this filter
*/
add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘my_facet’ == $params[‘facet_name’] ) { // change my_facet to your facet’s name/slug
if ( ‘1’ == $params[‘facet_value’] ) { // be careful with 1 and 0 as values – https://www.php.net/manual/en/types.comparisons.php
$params[‘facet_display_value’] = ‘My Label’; // text to display in the facet choices
}
}
return $params;
}, 10, 2 );

{{/gist}}