Revising my code example slightly,
function my_trim_overview( array $shared_attributes, \WP_Post $post ) {
// Fetch $overview_field here.
$overview_field = 'Some text';
// Trim to 20 words
$words = 20;
// Store the manual trimmed version for usage in the index.
$shared_attributes['overview_snippet'] = wp_trim_words( $overview_field, $words );
return $shared_attributes;
}
add_filter( 'algolia_searchable_post_shared_attributes', 'my_trim_overview', 10, 2 );
add_filter( 'algolia_post_shared_attributes', 'my_trim_overview', 10, 2 );
I’m changing the property to overview_snippet
instead of overview
in case you decide you want both versions in the object.
This would go in your active theme’s functions.php or anywhere else that you may have for where action/filter callbacks can be added to.
Then it should be available on data.overview_snippet
in the autocomplete/instantsearch.php template blocks, if I’m remembering my syntax properly.