Skip to main content

benecaster_episode_guests

Filter Free

Filters the list of guests the episode page’s Guests section shows. It starts as the name-and-website rows saved on the episode editor’s Guests tab.

Return the array. Cast with (array). Each row needs a name; role, bio and website are optional.

Returning an empty array suppresses the guests section entirely — the template returns, and the surrounding benecaster_before_/after_episode_guests actions do not fire either.

name and role are plain text, escaped on output, so markup in them becomes literal text. bio accepts post-level HTML: it is passed through wp_kses_post() before it is printed. website becomes the link on the name, opening in a new tab, and is dropped unless it is http or https. A row whose name is empty is skipped.

With Guest Manager. On a show where the Guest Manager add-on is on, an episode with at least one guest linked to it gets those guests in place of the free rows, never both, from a callback at the default priority (10). Each entry then carries name, role (the guest’s title and organization as one line, Founder, Acme Labs, or whichever is set), bio (the guest’s bio with paragraphs added), website, plus id and profile_url (the guest’s public page) for a theme override that wants them. A callback at a later priority sees the linked guests. An episode with no linked guest, or any episode on a show with Guest Manager off, still passes the free rows.

The guests show once. When Guest Manager’s Guests in this episode Episode Page block, or its [benecaster_guest_section] shortcode, has drawn an episode’s guests on the page, this filter returns an empty list for that episode, so the Guests section is not drawn as well. Returning '' from benecaster_episode_page_block_{slug} (benecaster_episode_page_block_guests) brings the section back; see Style, replace or hide Guest Manager’s Guests in this episode block.

Another plugin reading an episode’s linked guests should use benecaster_guest_manager_get_episode_guests() rather than this filter.

Parameters

Name Type Default Description
$guests array — The rows to show, each with at least a `name`
$episode_id int — ID of the episode

Returns: array

Example

add_filter( 'benecaster_episode_guests', function( $guests, $episode_id ) {
    // Append a co-host record from a custom taxonomy relationship.
    $cohost_id = (int) get_post_meta( $episode_id, '_episode_cohost_user_id', true );
    if ( $cohost_id ) {
        $user     = get_userdata( $cohost_id );
        $guests[] = [ 'name' => $user->display_name, 'role' => 'Co-host' ];
    }
    return $guests;
}, 10, 2 );

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