Skip to main content

benecaster_episode_card_classes

Filter Free

Filters the CSS class string on each episode card wrapper. Use to add conditional classes based on access, episode type, or custom meta.

Return a space-separated class STRING, not an array. Cast with (string), so returning [ 'a', 'b' ] produces the literal class Array — silently, and on every card.

Output through esc_attr(). The $can_access third parameter is the already-resolved access decision for the current visitor, so a callback can style locked cards without repeating the access check. Returning '' removes every class including core’s own, which usually breaks the card’s layout.

Parameters

Name Type Default Description
$classes string Space-separated CSS class string for the episode card wrapper
$episode_id int ID of the episode
$can_access bool Whether the current user can access this episode

Returns: string

Example

add_filter( 'benecaster_episode_card_classes', function( $classes, $episode_id, $can_access ) {
    // Mark bonus episodes with a distinct class for custom styling.
    $episode_type = get_post_meta( $episode_id, '_benecaster_episode_type', true );
    if ( 'bonus' === $episode_type ) {
        $classes .= ' episode-card--bonus';
    }
    if ( ! $can_access ) {
        $classes .= ' episode-card--locked';
    }
    return $classes;
}, 10, 3 );

Affects

  • archive/episode-card.php template part