Skip to main content

Suppress or override the feed redirect tag without changing stored settings

Free Beginner

The itunes:new-feed-url redirect tag is driven by stored post meta, but sometimes you need to suppress it for a specific tier feed without touching the settings — for example, when testing migration, or when only public tier feeds should carry the redirect. This recipe clears the new_feed_url key at compile time without modifying stored meta.

When to Use This

Use benecaster_feed_channel_data when:

  • You want to suppress the redirect tag during a staging or testing workflow without clearing the stored URL

  • Your add-on needs to route different subscriber tiers to different redirect destinations

  • You’re writing a tool that gives the admin temporary control over redirect behavior without permanent changes

How It Works

Everything here runs through one key. The filter receives the channel data array and the show ID; the redirect tag is rendered from its new_feed_url entry.

  • Suppress the tag by setting new_feed_url to an empty string.

  • Suppress conditionally — for a staging or testing workflow — by making that assignment depend on an option you control, so the redirect returns the moment you clear it.

  • Redirect somewhere else by assigning a different URL, guarding on the existing value being non-empty so you only override a redirect that was actually configured.

Notes

This only affects the current feed compilation. The stored _benecaster_show_new_feed_url post meta is untouched. If you remove this filter, the original redirect tag reappears immediately on the next feed request. To permanently remove the tag, delete the meta directly or use Settings → Show.

The new_feed_url key is always present in the channel data when a redirect is configured. If no redirect is configured, it is an empty string — there is nothing to suppress.

All other channel data keys are available. You can modify any key in the same callback — title, description, artwork, etc. See the benecaster_feed_channel_data reference for the full key list.

Related

Code

<?php
// Suppress the redirect tag for the free tier only.
add_filter( 'benecaster_feed_channel_data', function ( array $data, int $show_id ): array {
    // $tier_slug is available via the feed request context stored in the token.
    // For a tier-agnostic override, just clear the key unconditionally.
    $data['new_feed_url'] = '';
    return $data;
}, 10, 2 );

View on GitHub →

Hooks Used

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