Adding arg to search results page

That site you linked to is completely wrong. You should never ever use query_posts to run any type of query. Take your time and read the following post on this matter:

You also would not want to run any type of custom query in place of the main query, this raises/causes more issues than what it actually solves. You can also read the following post on this:

You should be using pre_get_posts to alter the main query to your needs. This is the correct way to alter what is being returned by the main query

add_action( 'pre_get_posts', function ( $q ) {
    if (    !is_admin() 
         && $q->is_main_query() 
    ) {
        $q->set( 'post_status', ['publish', 'future'] );
    }
});

Just remember, the code above effects all pages on the front end. This will even show future posts on single post pages as well which normally 404. You should adjust this to suite your specific needs

Leave a Comment