benecaster_related_episodes_output
Filters the final rendered HTML of the [benecaster_related_episodes] shortcode and the Related Episodes Episode Page block. Use to change the list markup, wrap the output in a custom container element, or suppress the output entirely when there are no results.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$html |
string |
— | Rendered HTML output |
$episodes |
WP_Post[] |
— | Episode WP_Post objects used to generate the output |
$atts |
array |
— | Resolved shortcode or block attributes |
Returns:
string
Examples
Wrap in accessible section element
add_filter( 'benecaster_related_episodes_output', function ( $html, $episodes, $atts ) {
if ( empty( $episodes ) ) {
return '';
}
return '<section class="related-episodes" aria-label="Related episodes">' . $html . '</section>';
}, 10, 3 );
Suppress output when no results
add_filter( 'benecaster_related_episodes_output', function ( string $html, array $episodes, array $atts ): string {
if ( empty( $episodes ) ) {
return '';
}
return '<section class="related-episodes">' . $html . '</section>';
}, 10, 3 );
Affects
- [benecaster_related_episodes] shortcode
- Related Episodes Episode Page block