FacetWP – index multiple field values for a single autocomplete facet

mgibbs189

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

// Add to functions.php
function fwp_combine_sources( $params, $class ) {
if ( ‘MY_FACET_NAME’ == $params[‘facet_name’] ) {

$value = get_field( ‘YOUR_FIELD_1’ );
$params[‘facet_value’] = sanitize_title( $value );
$params[‘facet_display_value’] = $value;
$class->insert( $params );

$value = get_field( ‘YOUR_FIELD_2’ );
$params[‘facet_value’] = sanitize_title( $value );
$params[‘facet_display_value’] = $value;
$class->insert( $params );

return false; // prevent default indexing
}
return $params;
}
add_filter( ‘facetwp_index_row’, ‘fwp_combine_sources’, 10, 2 );
{{/gist}}