I know I can publicly show future posts in a loop using 'post_status' => 'future'
in WP_Query. But clicking on a future post’s permalink will result in a 404 if you are not a logged-in user.
Suppose I have a post called Apocalypse in the post_type ‘event’, scheduled for 12-12-2099. The permalink is mysite.com/event/apocalypse. Is it possible to make mysite.com/event/apocalypse and other future ‘event’ posts visitable now by the public?
Ideally I’d be able to restrict future post availability to the ‘event’ post type, but I would settle for a solution that makes all future posts available regardless of post_type.
In short, you can make future posts visible by telling WordPress to mark them as
'published'
instead of'scheduled'
. You do this by using afuture_post
hook, which gets called when a post changes status. Each post type automatically gets its own future hook; since the custom post type I’m using isevent
, I can use thefuture_event
hook. Here is the code:This solution came from this SE question: Marking future dated post as published
I would like to give my answer all this time later. In the case of making all the ‘future’ posts for the ‘events’ post type visible to the public, I found this solution:
For me the given snippet didn’t worked, there were some errors in the post-edit.php, but I guess that $postatt is now null in 4.6.1.
Anyways that’s the final solution that worked for me like a charm.
I forced the publish status from functions.php of a child theme