elasticpress acf code example
Example 1: elasticpress acf
add_filter( 'ep_search_fields', 'update_search_fields', 11, 2 );
/**
* Updates fields to search against.
*
* @param array $fields List of searchable fields.
* @param array $args List of arguments provided.
*
* @return array
*/
function update_search_fields( array $fields, array $args ): array {
$fields[] = 'meta.mfr_part.value';
return $fields;
}
Example 2: elasticpress acf
/**
* ElasticSearch: Modify available search fields
*/
add_filter( 'ep_search_fields', function($search_fields, $args ) {
$fields = ['my_field'];
foreach($acf_fields as $key => $label) {
$fields[] = 'meta.'.$key.'.value';
}
return array_merge( $search_fields, $fields );
}, 10,2 );