benecaster_episode_duration
Filters the formatted duration string for an episode.
Return a duration string. Cast with (string). Feed-only — this does not affect the website.
Fires twice per episode: once for the standard episode data array in FeedCompiler and once for <itunes:duration> in ItunesNamespace. A callback must return a value acceptable to Apple Podcasts (HH:MM:SS, MM:SS, or total seconds); an unparseable string is emitted as-is and the validator, not the plugin, is what reports it. Returning '' omits a duration for that episode.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$duration |
string |
— | Formatted duration string (e.g. '1:23:45') |
$episode_id |
int |
— | ID of the episode |
Returns:
string
Example
add_filter( 'benecaster_episode_duration', function( $duration, $episode_id ) {
// Add an approximate label for long-form episodes (over 1 hour).
list( $h, $m ) = array_pad( explode( ':', $duration ), -3, 0 );
if ( (int) $h >= 1 ) {
$duration .= ' (~' . (int) $h . 'h)';
}
return $duration;
}, 10, 2 );
Need this built rather than just documented? See our services →