Allow anyone to view future posts of a certain post type (events) in WordPress

I have had a system on WordPress where events are scheduled posts and word great in loops.

However I just noticed that when clicking on an event and going to it’s page, it gives a 404. I can preview it when I’m logged in, however, I need to it to be visible by anyone even though it’s currently scheduled.

Read More

Is there a way to change permissions so that anyone can view a specific scheduled post type?

Thanks!

Related posts

Leave a Reply

3 comments

  1. Edited:

    Try adding this function to your functions.php file:

    /* Show future posts */
    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');
    
  2. Future posts are a bit of a Catch-22: You can query them in any good old-fashioned WordPress Loop, but navigating to them directly is not possible….. at least, within the standard WordPress Scope:

    <?php
    $q = new WP_Query(array('post_status'=>'future'));
    if($q->have_posts()) : while($q->have_posts()) : $q->the_post;
        echo '<a href="'.get_permalink().'">'.get_the_title().'</a>'; //404 when clicked
    endwhile;endif;
    ?>
    

    The reason for this is not because of permissions. It’s because that’s how it’s built in the WordPress Core. Future Posts are not intended to be viewable until a specific date. Trying to make future posts available for viewing is a misuse of the ‘future’ status and defeats its whole purpose which is to schedule a post or a page to automatically switch to a status of ‘Published’ when the designated date has been reached.

    If, however, you still want to make Future Posts available as if they’re normal posts, This discussion can probably shed some light on various methods and plugins to make everything happen the way you want.

    Good luck.