Last active
July 27, 2020 19:02
-
-
Save mgibbs189/23ea3e5ba81626586bc2a0f2739ab100 to your computer and use it in GitHub Desktop.
FacetWP - create meta-choices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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