0

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>
<?php
//The Query
query_posts(array(
'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);
?>
<dl>
<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>
</div>
<dd><?php the_excerpt(); ?></dd>
</dl>
<?php endwhile; ?>
</div><!--end boxerevents-->

Thanks for your help!

2

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' => '>=',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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