688 posts
  • 9 Years of Membership
  • Affiliate Level 1
  • Author Level 4
  • Collector Level 2
+3 more

I came across this thing, to show on the entire site the future posts, the content site needs that feature, to post future events, but i don´t want to use any plugin, just the same posts but in future, and visible for users on the entire site without the need to create customs querys for each template.

So, i decided to create a filter, but, i couldn´t find any information on how to do it, so i started to play some things….

And i build this two simple filters:

This one adds an arrgument to the global query, so you will see future posts on any loop:
function eventsFilter($query) {
    return $query;
This one let not logged visitor to see the future on single.php:
function signle_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', 'signle_future_posts');

Put that on functions.php and you have a new query on the entire site that will show also the future posts.

I need to check if works for the native calendar widget, but….

Once i discover this and taking in consideration the amount of comments all over the net asking how to do something like this, i can´t bellive was so easy.

I did this just 5 min. ago and i decided to share-right-now.


edited: sorry i created the thread on wrong area..

2468 posts
  • 8 Years of Membership
  • Exclusive Author
  • Author Level 2
  • Collector Level 2
+2 more

Cool, very useful!

Thanks _rg_ :)