benecaster_ai_search_guest_quotes
Filters a named guest’s passages that one search of the [benecaster_ai_search] box shows under In their own words: [ { guest_id, guest_name, episode_id, title, url, start, time, text } ], most relevant first, at most 5. A passage is in the list only when it is at least as close to the search as the search’s fifth-best episode, so the list may be short or empty even when a guest is named.
Runs after access is decided: each passage is already one the visitor may open and whose transcript they may see. Runs only when the search reached the ranking, never when the answer is unavailable.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$quotes |
array |
— | List of `{ guest_id, guest_name, episode_id, title, url, start, time, text }`; `start` is whole seconds into the base audio, `time` the same as m:ss or h:mm:ss |
$query |
string |
— | The search, trimmed |
$show_id |
int |
— | The show searched |
Returns:
array
Example
// Show one passage per episode, so a guest's words come from as many episodes as possible.
add_filter( 'benecaster_ai_search_guest_quotes', function ( array $quotes ): array {
$seen = [];
return array_values( array_filter( $quotes, function ( array $quote ) use ( &$seen ): bool {
if ( isset( $seen[ $quote['episode_id'] ] ) ) {
return false;
}
return $seen[ $quote['episode_id'] ] = true;
} ) );
} );
Notes
Anything you add is shown to the visitor as it is. Never add a passage from an episode or transcript the visitor may not see. A non-array return becomes an empty list. Walkthrough: Read or change what a guest said, in AI Search's answers.
Affects
- GET benecaster-ai-search/v1/search
- [benecaster_ai_search]
Need this built rather than just documented? See our services →