Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRebecca Jensen
11,580 PointsPosts are expiring too soon in PHP/Wordpress
I use this bit of code below to display upcoming events, and hide them once the date has passed.
It seemed to work correctly, until we had an evening event, and I discovered that the posts were expiring hours too soon! I have the proper timezone set in my Wordpress settings (Vancouver/Seattle), but that does not seem to make a difference.
I need to either fix the time zone problem, or overshoot and have the event expire the NEXT day. Any idea on how I can accomplish either?
<?php
$query = new WP_Query( array(
'post_type' => 'event',
'nopaging' => 'true',
'meta_key' => 'event_date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_value' => date('Ymd'),
'meta_compare' => '>=',
'date_query' => array(
array(
'key' => 'date',
'value' => date('Ymd'),
'compare' => '>=', //Greater than or equal to
'type' => 'DATETIME'
)
),
) );
?>