Skip to main content

Inject chapter markers from an external source

Free Beginner

Benecaster manages chapter data natively in the episode editor. Use this recipe when your chapter data lives in an external service — Podlove, Ausha, or a custom endpoint — and you want to emit a podcast:chapters tag pointing to a hosted JSON file rather than entering chapters manually. The filter runs at feed compile time and replaces whatever chapters are stored for the episode, so it takes full precedence.

Code

<?php
add_filter( 'benecaster_podcast_chapters', function ( array $chapters, int $episode_id ) {
    $chapters_url = get_post_meta( $episode_id, '_my_chapters_url', true );
    if ( ! $chapters_url ) {
        return $chapters;
    }
    return [
        'url'  => $chapters_url,
        'type' => 'application/json+chapters', // Podlove format (default if omitted)
    ];
}, 10, 2 );

View on GitHub →

Hooks Used

Need this built rather than just documented? See our services →