Skip to content

Instantly share code, notes, and snippets.

@djrmom
Last active May 29, 2020 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/114c13bdb93fe29d6e0f105e79888b75 to your computer and use it in GitHub Desktop.
Save djrmom/114c13bdb93fe29d6e0f105e79888b75 to your computer and use it in GitHub Desktop.
facetwp change a numeric value to a label
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment