Show scheduled posts in archive page

Keep things simple – leave your archive templates alone and place this in your functions.php;

add_action( 'pre_get_posts', function ( $wp_query ) {
    global $wp_post_statuses;

    if (
        ! empty( $wp_post_statuses['future'] ) &&
        ! is_admin() &&
        $wp_query->is_main_query() && (
            $wp_query->is_date() ||
            $wp_query->is_single()
        )
    ) {
        $wp_post_statuses['future']->public = true;
    }
});

Essentially, it says;

If we’re on a date archive, or viewing a single post, make future posts publicly visible.

As a result, WordPress behaves normally when you view archives for any given date, except now it also includes posts ‘from the future’!.

Leave a Comment