FacetWP – get county name from code

mgibbs189

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

// Add the following to your (child) theme’s functions.php file
// Then re-index afterwards

add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘country’ == $params[‘facet_name’] && 2 == strlen( $params[‘facet_value’] ) ) {
$params[‘facet_display_value’] = locale_get_display_region( ‘-‘ . $params[‘facet_value’], ‘en’ );
}
return $params;
}, 10, 2 );

{{/gist}}