Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

These Wordpress filters demonstrate two methods to publish (and view) posts in the future. Great for events, etc.

View gist:6166280
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
add_filter( 'wp_insert_post_data', 'publish_future' );
 
/* Avoid publishing posts as 'future' in the first place.
function publish_future( $data ) {
if ( $data['post_status'] == 'future' && $data['post_type'] == 'post' )
$data['post_status'] = 'publish';
return $data;
}
 
 
/* Show future posts even if they aren't published - maintains 'future' post_status */
function show_future_posts($posts)
{
global $wp_query, $wpdb;
if(is_single() && $wp_query->post_count == 0)
{
$posts = $wpdb->get_results($wp_query->request);
}
return $posts;
}
add_filter('the_posts', 'show_future_posts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.