FacetWP – combine multiple fields for an Autocomplete facet

mgibbs189

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

// Add to functions.php
// Replace FIRST, MIDDLE, LAST with the actual field names
function fwp_combine_sources( $params, $class ) {
if ( ‘full_name’ == $params[‘facet_name’] ) {
$full_name = get_field( ‘FIRST’ ) . ‘ ‘ . get_field( ‘MIDDLE’ ) . ‘ ‘ . get_field( ‘LAST’ );
$params[‘facet_value’] = sanitize_title( $full_name ); // URL-safe string
$params[‘facet_display_value’] = $full_name;
}
return $params;
}
add_filter( ‘facetwp_index_row’, ‘fwp_combine_sources’, 10, 2 );
{{/gist}}