Skip to main content

benecaster_ai_search_pinned_results

Filter Premium ai-search

Filters the pinned results firing for one search in the benecaster_ai_search box, in the order they are placed. Each entry is { post_id, keyword, priority }: add, drop or reorder them. The podcaster manages pins on Show Settings → AI Search; a pin fires when the visitor’s query contains its words, ignoring case and spacing, ordered by priority (lower first) and then oldest first.

Every entry is still checked. Only an episode of the show searched, or a published post or page with no password, is placed, and access still decides how: a pinned episode the visitor cannot open is left out of a hidden box and is a lock card in a locked one. Pinned results come before the ranked ones, are removed from further down, and count toward the 10 results.

Parameters

Name Type Default Description
$pins array — List of `{ post_id, keyword, priority }`
$query string — The search, trimmed
$show_id int — The show searched

Returns: array

Example

// During a live event, pin the event page for "live" on show 12, ahead of the podcaster's own pins.
add_filter( 'benecaster_ai_search_pinned_results', function ( array $pins, string $query, int $show_id ): array {
    if ( 12 === $show_id && false !== stripos( $query, 'live' ) ) {
        array_unshift( $pins, [ 'post_id' => 345, 'keyword' => 'live', 'priority' => 0 ] );
    }
    return $pins;
}, 10, 3 );

Notes

Pins cost nothing, so they are applied even when the provider could not rank or the show reached its daily limit. The production panel's admin search shows the ranking unpinned. Walkthrough: Manage or change AI Search's pinned results.

Affects

  • [benecaster_ai_search] shortcode
  • GET benecaster-ai-search/v1/search

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