benecaster_related_episodes_query_types
Registers additional query strategies for the Related Episodes block and shortcode. Each key in the returned array is a type slug; each value is a plain array with a label and a results callable. There is no interface to implement and no class name to know.
New types appear automatically in the query type selector in the Episode Page settings panel and are available as the type attribute of the benecaster_related_episodes shortcode. Tier-aware filtering is handled by the renderer — a strategy returns all matching published episodes and does not filter by subscriber access. Built-in types: by_tag, by_season, by_guest, latest.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$types |
array |
— | Keyed array of strategy definitions: slug => [ 'label' => string, 'results' => callable ]. |
Returns:
array
Example
add_filter( 'benecaster_related_episodes_query_types', function ( array $types ): array {
$types['by_series'] = [
'label' => __( 'Same series', 'my-addon' ),
'results' => function ( int $episode_id, int $show_id, array $args ): array {
$series = get_post_meta( $episode_id, 'my_series', true );
if ( ! $series ) {
return [];
}
return get_posts( [
'post_type' => 'benecaster_episode',
'post_parent' => $show_id,
'posts_per_page' => $args['count'],
'post__not_in' => $args['exclude_current'] ? [ $episode_id ] : [],
'meta_key' => 'my_series',
'meta_value' => $series,
] );
},
];
return $types;
} );
Notes
results receives ( int $episode_id, int $show_id, array $args ) — episode first. The sibling filter benecaster_member_thanks_query_types takes the same two IDs in the opposite order. They are easy to transpose and PHP will not stop you, because both are integers.
$args carries count (int) and exclude_current (bool); honour both. Return a list of WP_Post objects.
An entry whose results is missing or not callable is silently discarded, not fataled — so a strategy that never appears in the picker is usually a malformed definition rather than a registration failure. Do not reuse a built-in slug (by_tag, by_season, by_guest, latest) as your own key.
Affects
- benecaster_related_episodes shortcode
- Related Episodes Episode Page block
- Settings → Show → Episode Page query type picker
Need this built rather than just documented? See our services →