Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Last active July 27, 2020 19:02
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 mgibbs189/23ea3e5ba81626586bc2a0f2739ab100 to your computer and use it in GitHub Desktop.
Save mgibbs189/23ea3e5ba81626586bc2a0f2739ab100 to your computer and use it in GitHub Desktop.
FacetWP - create meta-choices
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment