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.
Thanks for this, Brian! I was able to get the future (scheduled) posts to show up! However, when I’m on a single (Events) page, the pagination doesn’t work. It’ll show links to “published” posts, but not to “scheduled” posts. I’m using a custom post type called “event”.
I tried using this code on Stack Exchange, and it works, but it also shows future posts for other post types, not the “event” post type only. Any ideas how to get that to work?
Here’s the code I used, but can’t get it to work for just the specific post type only of “event”:
Unfortunately, I think you’d need to more or less build this from scratch. These functions are premade to look for specific types of posts. You’d need to build your own query for a custom post type, get the publish date of all posts, sort them, choose the ones that are closest, get the permalinks of each of those, and then generate the links.
I don’t know of an easy way off-hand to shortcut just building that.
Pingback: Get ID of Current Category - WordPress | BJD
Pingback: Change Number of Results in Loop: Wordpress Brian Johnson's Design Blog