benecaster_get_public_feed_url()
benecaster_get_public_feed_url( int $show_id ): ?string
Returns the canonical public (un-gated) feed URL for a show — the URL at /podcast-feed/{slug}/ that anyone can access without a subscriber token. Use this helper from theme code, add-on callbacks, or template overrides whenever you need a “listen anywhere” public-tier link without inlining the URL pattern.
Never redirect a feed request to this URL. It is the exact URL the ^podcast-feed/([^/]+)/?$ rewrite rule dispatches straight back into FeedController::maybe_dispatch(), so a redirect issued from anywhere in the feed pipeline points at the request it was called on. That was a real defect, not a hypothetical one: the Day-30 hard-cutoff path used to 302 here with Cache-Control: public, max-age=3600 on it — an infinite loop, cached for an hour — and because it ran before token resolution it fired on anonymous requests too, so a stranger asking for the free public feed got the loop. Feeds now go dark with a 403 and there is no fallback redirect anywhere in the pipeline; see FeedController::feed_is_dark().
The function itself is unchanged and is not deprecated. Rendering links is what it is for. Using it keeps your code in sync with any future change to the public feed URL structure.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
$show_id |
int |
— | Yes | WordPress post ID of the show. |
Return Value
Type:
string|null
The fully-qualified public (un-gated) feed URL for the show, e.g. https://example.com/podcast-feed/my-show/. Returns null when the show has no feed slug configured.
Example
$public_url = benecaster_get_public_feed_url( 42 );
if ( $public_url ) {
echo '<a href="' . esc_url( $public_url ) . '">Listen free</a>';
}
Notes
Returns null when the show's feed slug field is empty. Check the return value before using it in a link — and not in a redirect, per the warning above. The URL is not validated against the server: it is constructed from the stored slug and the site's home_url().
Need this built rather than just documented? See our services →