Skip to main content

Style, replace or hide Guest Manager’s Guests in this episode block

Premium Intermediate Guest Manager

Guest Manager adds a Guests in this episode Episode Page block. The podcaster switches it on per show under Show Settings → Templates → Episode Page Blocks → After Content; it is off by default. It is registered under the block key guests, with position after and no settings, and needs Guest Manager on for the show.

  • What it draws. The episode’s linked guests, as benecaster_guest_manager_get_episode_guests() returns them, in the episode’s order, only on a show with Guest Manager on. It draws nothing ('') for an episode with no linked guest.
  • The markup, which themes can rely on: <div class="benecaster-block benecaster-guests-block"><h2 class="benecaster-section-heading">Guests</h2><ul class="benecaster-guests-list">, then per guest <li class="benecaster-guest"> holding, each only when the guest has it: <img class="benecaster-guest-photo" … width="96" height="96" alt=""> (the photo’s thumbnail size), <span class="benecaster-guest-name"> (the name, linked to the guest’s Website in a new tab when they have one), <span class="benecaster-guest-role"> (title and organization as one line, Founder, Acme Labs, or whichever is set) and <p class="benecaster-guest-bio"> (the bio as plain text, cut to its first 30 words with …). The list classes match the episode page’s own Guests section, so one set of styles covers both. Guest Manager adds no stylesheet.
  • The guests show once. When the block’s HTML is not empty for an episode, after every callback on benecaster_episode_page_block_{slug} (here benecaster_episode_page_block_guests), Guest Manager hands the episode page’s Guests section an empty list for that episode through benecaster_episode_guests, so that section is not drawn. Returning '' from benecaster_episode_page_block_guests therefore brings the section back. This relies on the block running before the guests section, as Benecaster’s episode/single.php template does; a theme override that draws episode/guests before the content shows both.
  • A locked episode draws no block. A visitor without access sees the teaser, which does not run Episode Page blocks, so that visitor sees the episode page’s own Guests section instead.

Code

<?php
// Put the guests in a card grid of your own, keeping Guest Manager's data and order.
add_filter( 'benecaster_episode_page_block_guests', static function ( string $html, int $episode_id ): string {
    if ( '' === $html ) {
        return $html; // No linked guest, or Guest Manager off for this show.
    }
    $cards = array_map(
        static fn( array $g ): string => sprintf( '<li><a href="%s">%s</a></li>', esc_url( $g['profile_url'] ), esc_html( $g['name'] ) ),
        benecaster_guest_manager_get_episode_guests( $episode_id )
    );
    return '<ul class="my-guest-grid">' . implode( '', $cards ) . '</ul>';
}, 10, 2 );

View on GitHub →

Hooks Used

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