Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created December 18, 2017 22:02
Show Gist options
  • Save djrmom/782899192b4408f4f9dd29dbbc8a4119 to your computer and use it in GitHub Desktop.
Save djrmom/782899192b4408f4f9dd29dbbc8a4119 to your computer and use it in GitHub Desktop.
<?php
/* convert state into region */
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'region' == $params['facet_name'] ) {
$northwest = array( 'WA', 'OR', 'MT');
$northeast = array( 'ME', 'VT', 'MA', 'NH' );
$raw_value = $params['facet_value'];
if ( in_array( $raw_value, $northwest ) ) {
$params['facet_value'] = 'northwest';
$params['facet_display_value'] = 'North West';
} elseif ( in_array( $raw_value, $northeast ) ) {
$params['facet_value'] = 'northeast';
$params['facet_display_value'] = 'North East';
}
}
return $params;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment