Show an episode duration in a custom template
Benecaster stores a duration as 00:47:23, which podcast apps need, and its own episode cards show hours and minutes, 0:47. A theme override of archive/episode-card/meta.php, or a custom episode list, can match the cards with benecaster_format_duration(), including any format the site has chosen with benecaster_duration_display.
Code
<?php
// In a theme template, inside a loop over benecaster_episode posts.
$duration = function_exists( 'benecaster_format_duration' )
? benecaster_format_duration( (string) get_post_meta( get_the_ID(), '_benecaster_duration', true ) ) // 00:47:23 → 0:47, 01:02:03 → 1:02
: '';
if ( $duration !== '' ) {
printf( '<span class="my-episode-duration">%s</span>', esc_html( $duration ) );
}
Hooks Used
Need this built rather than just documented? See our services →