mgibbs189

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

add_filter( ‘facetwp_indexer_row_data’, function( $rows, $params ) {
if ( ‘locations’ == $params[‘facet’][‘name’] ) {
$post_id = (int) $params[‘defaults’][‘post_id’];
$location = get_field( ‘locations’, $post_id ); // returns an post object
$field_value = get_field( ‘postcode’, $location->ID );
$new_row = $params[‘defaults’];
$new_row[‘facet_value’] = $field_value; // value
$new_row[‘facet_display_value’] = $field_value; // label
$rows[] = $new_row;
}
return $rows;
}, 10, 2 );
{{/gist}}