Change or wrap the AI Search box’s markup
Put a heading, a wrapper or your own copy around the AI Search box, or replace its markup, with the benecaster_ai_search_output filter. It receives the complete markup of one benecaster_ai_search box and its resolved attributes. 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_outputis 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, whoseidis unique per box),__form,__label,__row,__input,__submitand__results(the region results are drawn into). The base stylesheet wraps every rule in:where(), so any theme rule wins without raising specificity. - Keep the form, the input, the Search button and the
__resultsregion 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 tag exists only while AI Search is switched on for at least one show. Check
shortcode_exists( 'benecaster_ai_search' )before callingdo_shortcode()with it. - The filter runs only when the box renders. The box renders nothing, and the filter is not called, when no show resolves (the
show_idattribute, then the show or episode page, then the site’s only show) or when AI Search is switched off for that show.
Code
<?php
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 );
Hooks Used
Need this built rather than just documented? See our services →