Display a post’s publish date from 2112

I had the same issue as you when I was dealing with events and wanted to show future events.

Here is what I coded:

add_action( 'init', 'change_future_posts_to_post_now' );
function change_future_posts_to_post_now() {
    remove_action("future_post", '_future_post_hook');
    add_action("future_post", 'publish_future_posts_now', 2, 10);
}

function publish_future_posts_now($depreciated, $post) {
    wp_publish_post($post);
}


add_filter('posts_where', 'show_future_posts_where', 2, 10);
function show_future_posts_where($where, $that) {
    global $wpdb;
    if("post" == $that->query_vars['post_type'] && is_archive())
        $where = str_replace( "{$wpdb->posts}.post_status="publish"", "{$wpdb->posts}.post_status="publish" OR {$wpdb->posts}.post_status="future"", $where);
    return $where;
}

Please see here How to set a custom post type to have viewable future posts where I had the same question when dealing with a CPT.

Leave a Comment