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.
Is there a way to change permissions so that anyone can view a specific scheduled post type?
Thanks!
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.
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');
I tried several plugins and suggestions for this problem, but none worked to show a single custom post type template page to non-logged in users. Eventually I found my answer:
https://wordpress.stackexchange.com/questions/44202/how-to-set-a-custom-post-type-to-have-viewable-future-posts/70155#70155