All I'm trying to do here is a simple custom loop using WP_Query to display posts if they are published in the last 24 hours; otherwise, a message appears telling the user to check back soon for fresh posts. I'm trying to use the date_query parameter in my arguments but I'm getting unexpected results...at first it will work, but if I check the page in a few minutes, its as if it reset itself... my loop is set up below:
$args = array(
'post_type' => 'surf_reports',
'posts_per_page' => '1',
'category_name' => $cat (this is pulled dynamically in my template),
'date_query' => array(
'before' => strtotime('-24 hours')
)
);
And then obviously below there would be a loop, I'm not going to share that bc its standard and I believe unrelated to the issue.
strtotime()
strings. Please let us know if that's not the problem here.