0

On the homepage of my website I'm retrieving published and scheduled posts this way:

<?php 
global $post;
$args = array('numberposts' => '3', 'category' => $category, 'post_status' => array('publish', 'future' ));
$myposts = get_posts($args);

It works fine, but if I'm not logged in as admin I can't access the whole post. It gives me a 404 error.

1 Answer 1

1

I assume what you are doing is pulling 3 posts, one or more of which may be 'Future' posts, displaying some kind of preview and a link to the complete post. When you click the link for 'Future' posts, you get the error.

'Future' posts are going to be blocked for people not capable of editing them, more or less the way 'Drafts' are blocked. Attempting to access those results in a 404. That is how the system works. Nothing is broken here. Nearly everything can be overridden but why would you schedule a post and then try to display it before its scheduled time?

2
  • It's a website I built for an organization. They public news and upcoming events, so they want to display also future posts and I thought scheduled posts worked as I expected them to, but I was wrong. So, is there a neat way to do what I need?
    – Carlo
    Commented Oct 18, 2012 at 13:54
  • No, 'future' posts aren't a 'calender' feature. You will need to look in the Plugin Repo for 'event' plugins, probably, or write your own scheduler, or use a third party service.
    – s_ha_dum
    Commented Oct 18, 2012 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.