It’s actually quite easy to include future posts in a WordPress loop using a simple query_posts with some arguments. Other information on the web makes it sound like it’s really tricky, but those people are either misinformed or lying. Let’s take a look!
This tutorial assumes you are familiar with the use of query_posts to start a new query. If not, head over to the WordPress Codex and take a look at the page on query_posts. While this isn’t the preferred method to run a query, it’s fairly simple to implement and accomplish what you want. If someone with more talent than me can adapt this to work with pre_get_posts or something, I would love to see how!
Displaying the Future Posts
The magic here happens by specifying post_status as ‘future’ in your arguments. Now, there are two ways to specify the arguments for query_posts. One would look like this:
query_posts( 'post_status=future' );
What that code would do is query all regular posts that are scheduled to be published in the future.
Note that this last method will exclude older posts. But what if we want to display future AND past posts? We can do that! Unfortunately string arguments for query_posts will only allow us to specify one “post_status”, so we will need to set up an $args array. Here’s what that would look like:
Displaying Future AND Published Posts
$args = array(
'post_status' => array('publish', 'future'),
query_posts( $args );
This is definitely the preferred way to do this, as you have greater control over your arguments. This method will also list all future and published posts, instead of just the future, unpublished posts. As you can see, it’s extremely easy to implement and gets the job done.
You could also change the number of posts to display using wp_query quite simply. Utilizing various arguments, you can further define what shows up!
If you have any questions about this, ask it in the comments or tweet me @brianjonline.