Skip to main content

Redirect feed URLs to pretty permalink format

Free Beginner Since v1.0.0

By default Benecaster builds token URLs using a query parameter format. Use this recipe to rewrite them to a pretty permalink structure — e.g. /podcast/feed/abc123xyz — that looks cleaner in email copy and is easier for subscribers to share or remember.

Code

<?php
// Switch from ?token= query-string format to /feed/{token} pretty permalink.
// Add this to functions.php or a site-specific plugin.
add_filter(
    'benecaster_token_url',
    function ( string $url, string $token, int $show_id, int $user_id ): string {
        // Replace https://site.com/podcast-feed/?token=<hex>
        // with   https://site.com/podcast-feed/<hex>
        return home_url( '/podcast-feed/' . $token );
    },
    10,
    4
);

View on GitHub →

Hooks Used