Skip to main content

Show or hide a show’s public episode pages from add-on code

Free Intermediate

A show’s episode pages can be hidden from the public site independently of anything to do with feeds or subscriptions. Two separate switches control it: one hides the individual episode pages, the other removes that show’s episodes from the archive listing. They are independent on purpose — you can leave episodes reachable by direct link while keeping them out of the listing, or the reverse.

Useful for a launch that goes public at a set time, an import that should stay invisible until somebody has reviewed it, or a paywall add-on doing its own gating.

Set these through the provided accessors, not by writing the underlying post meta. The stored form is not the plain true/false you would expect, and writing it by hand produces a value that reads back wrong — a show you believe is hidden, and is not. That failure is silent and shows up as content being public when it should not be.

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 );
} );

View on GitHub →

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