benecaster_podcast_chapters
Filters the chapter file reference for an episode before the RSS feed is compiled. The returned array populates the Podcasting 2.0 `podcast:chapters` RSS element — an external JSON chapters file URL that compatible podcast apps fetch to display interactive chapter markers during playback.
Benecaster includes a built-in chapter marker editor that populates this filter automatically for each episode. Use this filter to override the chapter reference programmatically — for example, to supply a URL from a third-party chapter tool — or return an empty array to suppress the `podcast:chapters` element from the feed entirely. Unlike transcripts, each episode references a single external chapter file. For Podlove Simple Chapters (`psc:chapters`) output, use the [benecaster_psc_chapters](/hooks/benecaster_psc_chapters/) filter instead.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$chapters |
array |
— | Default []. Array of chapter objects {url: string, type: string} |
$episode_id |
int |
— | ID of the episode |
Returns:
array{url: string, type: string}
Examples
Load chapter file URL from post meta
add_filter( 'benecaster_podcast_chapters', function ( $chapters, $episode_id ) {
$json_url = get_post_meta( $episode_id, '_mychapters_json_url', true );
if ( $json_url ) {
$chapters[] = [ 'url' => $json_url, 'type' => 'application/json+chapters' ];
}
return $chapters;
}, 10, 2 );
Replace with URL from dedicated meta key
add_filter( 'benecaster_podcast_chapters', function ( array $chapters, int $episode_id ): array {
$url = get_post_meta( $episode_id, '_chapters_json_url', true );
if ( ! $url ) {
return $chapters;
}
return [
'url' => esc_url( $url ),
'type' => 'application/json+chapters',
];
}, 10, 2 );
Notes
Compatible podcast apps expect application/json+chapters as the MIME type for Podcasting 2.0 chapter JSON files. The chapter file URL must be publicly accessible — Benecaster does not proxy or cache it.