So I am making a news website about the future, 2112 to be specific (hello, critics). I wanted to display a post’s date to be from 2112. But when I try to do this from the admin panel, it ‘schedules’ the post. I really want to publish the post in this century. Any help, people?
4 s
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.