Show or hide a show’s public episode pages from add-on code
ShowMeta exposes set_episode_single_pages_disabled( bool ), set_episode_archive_disabled( bool ), and their read counterparts. Use them programmatically to gate a show’s public visibility — useful for time-locked launches, paywall integrations, or import workflows that want shows invisible until reviewed. The single-page flag 404s only that show’s episode URLs; the archive flag excludes that show’s episodes from the listing via pre_get_posts. Do NOT read or write the underlying post_meta keys directly — use the accessors which normalize the '1'/'0' encoding.
Code
<?php
use Benecaster\Show\ShowMeta;
// Lock a show to the private feed for 30 days after publish, then reveal.
add_action( 'benecaster_show_created', function ( int $show_id ): void {
$meta = new ShowMeta( $show_id );
$meta->set_episode_single_pages_disabled( true );
$meta->set_episode_archive_disabled( true );
wp_schedule_single_event( time() + 30 * DAY_IN_SECONDS, 'my_addon_reveal_show', [ $show_id ] );
} );
add_action( 'my_addon_reveal_show', function ( int $show_id ): void {
$meta = new ShowMeta( $show_id );
$meta->set_episode_single_pages_disabled( false );
$meta->set_episode_archive_disabled( false );
} );