Skip to main content

benecaster_ai_search_output

Filter Premium ai-search

Filters the complete markup of one benecaster_ai_search box before it is returned. Wrap it, add to it or replace it. Return '' and the box renders nothing, and its stylesheet (handle benecaster-ai-search-widget) is not loaded on that page.

It is AI Search’s own filter. benecaster_search_output is for the keyword search box [benecaster_search] only and never sees this box; the two boxes share no class, id, stylesheet or filter, so a page can hold both.

The markup’s classes are a stable hook for themes: benecaster-ai-search (the wrapper, whose id is unique per box), __form, __label, __row, __input, __submit and __results (the region results are drawn into). The base stylesheet wraps every rule in :where(), so any theme rule wins without raising specificity.

Parameters

Name Type Default Description
$html string — The box's complete markup
$atts array — The box's resolved attributes: `show_id`, `placement`, `result_visibility`, `locked_cta_url`, `locked_cta_label`

Returns: string

Example

add_filter( 'benecaster_ai_search_output', function ( string $html, array $atts ): string {
    return '<section class="my-ask-the-archive"><h2>' . esc_html__( 'Ask the archive', 'my-theme' ) . '</h2>' . $html . '</section>';
}, 10, 2 );

Notes

Keep the form, the input, the Search button and the __results region if you change the markup: the box's script finds them by class. The box searches when the visitor presses Search or Enter, never as they type, because each search is a paid call to the podcaster's provider. The filter runs only when the box renders: not when no show resolves, nor when AI Search is switched off for that show. Walkthrough: Change or wrap the AI Search box's markup.

Affects

  • [benecaster_ai_search] shortcode

Need this built rather than just documented? See our services →