Here is what I came up with. Seems to be working. If anyone has suggestions for improvement, I’m all ears:
// Redirect links to future posts to Coming Soon page.
add_action('wp','redirect_coming_soon_posts', 0);
function redirect_coming_soon_posts(){
global $wpdb;
if ($wpdb->last_result[0]->post_status == "future" &&
$wpdb->last_result[0]->post_date_gmt != '0000-00-00 00:00:00' &&
! is_admin() ):
session_start();
$_SESSION['next_post_id'] = $wpdb->last_result[0]->ID;
wp_redirect( '/coming-soon', 301 );
exit();
endif;
}
function sess_start() {
if (!session_id()) {
session_start();
}
}
add_action('init','sess_start');