FacetWP – create meta-choices

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

// Add to your (child) theme’s functions.php and re-index afterwards!

add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘recognition’ == $params[‘facet_name’] ) {
$new_params = $params;
$label = $params[‘facet_display_value’];

if ( false !== strpos( $label, ‘National Winner’ ) ) {
$new_params[‘facet_value’] = ‘national-winners’;
$new_params[‘facet_display_value’] = ‘All National Winners’;
$class->insert( $new_params );

$new_params[‘facet_value’] = ‘all-winners’;
$new_params[‘facet_display_value’] = ‘All Winners’;
$class->insert( $new_params );
}

if ( false !== strpos( $label, ‘Place in School’ ) ) {
$new_params[‘facet_value’] = ‘all-winners’;
$new_params[‘facet_display_value’] = ‘All Winners’;
$class->insert( $new_params );
}
}

return $params;
}, 10, 2 );

{{/gist}}