Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I currently have some code setup to display upcoming events set by the admin based on the date of the event. The upcoming events are sorted by the next upcoming event, starting from the top, and then going down. I've limited it to just two.

But, when the start of the day comes (e.g. midnight of event date), the event disappears. I'd like the event to still show through midnight of the next day (e.g. the start of the next day). Right now, the event is disappearing the second that the day of the event comes...

Does anyone know how to change this with the current code that I have?

<div class="boxer events">
<h3>Upcoming Events</h3>
//The Query
'posts_per_page' => 2,
'meta_key' => 'event_date',
'meta_value' => date('Y-m-d'),
'meta_compare' => '>',
'orderby' => 'meta_value',
'order' => 'ASC'

//The Loop
$count = 0;
while ( have_posts() ) : the_post(); $count++;
//The Title
$title = $post->post_title;
$event_datee = get_post_meta($post->ID, 'event_date', true);
<dt><a title="<?php echo $title; ?>" href="<?php the_permalink(); ?>"><?php echo $title; ?></a></dt>
<div class="postdate">
<div class="month m-<?php $dtes = get('event_date'); $timestamp = strtotime($dtes); echo date('n', $timestamp); //month ?>"></div>
<div class="day d-<?php $dtes = get('event_date'); $timestamp = strtotime($dtes); echo date('d', $timestamp); //day ?>"></div>
<div class="year y-<?php $dtes = get('event_date'); $timestamp = strtotime($dtes); echo date('Y', $timestamp); //year ?>"></div>
<dd><?php the_excerpt(); ?></dd>
<?php endwhile; ?>
</div><!--end boxerevents-->

Thanks for your help!

share|improve this question
add comment

1 Answer

If I understand right your current logic is "events later than today" but you want to adjust it to "events today or later".

This should be simple by adjusting comparison rule to from "more" to "more or equal":

'meta_compare' => '>=',
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.