Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7508293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:39:19+00:00 2026-05-29T22:39:19+00:00

So I have a loop that runs perfect for events and only shows future

  • 0

So I have a loop that runs perfect for events and only shows future posts. The issue is that I would love to keep posts that are no longer future posts in the loop for an extra day.

Example:
So if the event (or post that is scheduled) is for 8pm on the 3rd. As of now it is removed at 8pm (which is an issue because it might last for 4 hours).

I would like posts to remain up for an extra day, or time that I would be able to alter.

Here is my current code:

<?php
                    $args = array( 'post_type' => 'event', 'posts_per_page' => 50, 'post_status' => 'future', 'order' => 'ASC' );
                    $loop = new WP_Query( $args );
                    if ( have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();?>
                        <div class="teaser-event <?php the_field('highlight') ?>">
                            <div class="event-meta gold">
                            <div class="event-date"><?php the_time('M d'); ?></div>
                                <div class="event-time"><?php the_time('g:i A'); ?></div>
                            </div>
                            <div class="event-title">
                                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
                                    <?php the_title(); ?>
                                </a>
                            </div>
                        </div>
                        <?php  endwhile; else: ?>
                        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
                    <?php endif; ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:39:19+00:00Added an answer on May 29, 2026 at 10:39 pm

    It seems like the time parameters for WP_Query are able to specify definite time spans but not indefinite ones, e.g. posts from now into the future. The WordPress docs recommends using the posts_where filter for time-relative queries. So you might put this in your theme’s functions.php:

    // Create a new filtering function that will add our where clause to the query
    function filter_where($where = '') {
        // posts from yesterday into the future
        $where .= ' AND post_date >= "' . date('Y-m-d', strtotime('-1 day')) . '"';
        return $where;
    }
    

    And in your code above you could do:

    $args = array('post_type' => 'event', 'posts_per_page' => 50, 'order' => 'ASC');
    add_filter('posts_where', 'filter_where');
    $loop = new WP_Query($args);
    remove_filter('posts_where', 'filter_where');
    if ( have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
    

    The adding and removing filter doesn’t make this the most elegant solution, so you could probably clean it up by defining a custom function get_recent_and_future_posts() in your theme’s functions.php that returns whatever object $loop is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Win32 program that runs on a loop. I would like to
I have a loop that runs through a variety of websites and I'd like
I have a loop that runs for approx. 25 minutes i.e 1500 seconds. [100
I have a thread that appends rows to self.output and a loop that runs
I have written a C# app that runs constantly in a loop and several
So I have a Linux program that runs in a while(true) loop, which waits
I have the following situation: I have a certain function that runs a loop
I have a thread in Ruby. It runs a loop. When that loop reaches
Short Question I have a loop that runs 180,000 times. At the end of
Suppose we have a loop that runs for 100 times. Does using unsigned char

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.