Skip to main content

Place guests anywhere with Guest Manager’s shortcodes

Premium Beginner Guest Manager

Guest Manager has three shortcodes, which the Blocks & Widgets add-on also offers as blocks and Elementor widgets. Their tags, attributes and attribute values are permanent: later versions only add. Switches read false, 0, no and off as false and anything else as true.

They are registered on every request, so a page never prints a tag as text, and each draws nothing unless Guest Manager is on for at least one show. Test for a tag with shortcode_exists().

  • benecaster_guest_section episode_id="0" title="Guests" bio="excerpt" photos="true": an episode’s linked guests in the episode’s order, with the markup of the Guests in this episode block inside <div class="benecaster-guest-section">. Draws nothing for an episode whose own show has Guest Manager off. When it draws for an episode, the episode page’s own Guests section steps aside for that episode, so the guests show once. Its HTML passes through benecaster_guest_manager_guest_section_output ( string $html, int $episode_id, array $atts ).
  • benecaster_guests title="Guests" search="true" per_page="30" show="": the public guest directory’s list on any page, whether or not /guests/ is switched on. show narrows it: empty for every show (the default), a show’s id or slug, or current for the show of the page being viewed (a show’s page, an episode’s show, or a show’s guest directory; every show anywhere else). A show that is unknown, not published or has Guest Manager off lists nobody (No guests yet.), never every show. The search covers the chosen show’s guests only, and the list never draws /guests/‘s Show select. The list passes through benecaster_guest_manager_guest_directory_data, then the HTML through benecaster_guest_manager_guests_output ( string $html, array $directory, array $atts ). Template guest/directory-list.php ($directory, $title, $heading_tag h1 or h2, $show_search, $all_url), the same part the directory page draws.
  • benecaster_guest guest="" bio="excerpt" photo="true" links="true" publications="false": one guest’s card. Its HTML passes through benecaster_guest_manager_guest_output ( string $html, int $guest_id, array $atts ). Template guest/card.php, with $card: guest_id, name, url (the guest page), title_line (Title, Organization), photo_url, bio, bio_is_html, website, social, publications, publications_disclosure. Markup div.benecaster-guest-card (__photo, __body, __name, __title, __bio, __links). publications="true" draws the guest’s publications after the links through guest/publications.php (see Restyle a guest’s publications).

WordPress’s own shortcode_atts_{tag} filters run on each. Guest Manager adds no stylesheet; images carry width and height. Override a template by copying it to {theme}/benecaster/guest/.

Code

<?php
// A guest card in a theme template, only where Guest Manager can draw one.
if ( shortcode_exists( 'benecaster_guest' ) ) {
    echo do_shortcode( '[benecaster_guest guest="ada-lovelace" bio="none"]' );
}

// Never show a full bio in a card on the front page, whatever the shortcode says.
add_filter( 'shortcode_atts_benecaster_guest', static function ( array $atts ): array {
    if ( is_front_page() && 'full' === $atts['bio'] ) {
        $atts['bio'] = 'excerpt';
    }
    return $atts;
} );

View on GitHub →

Hooks Used

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