I'd like to get the closest post to today's post; yes, I checked and search this topic and found the code working for me:
date_default_timezone_set("Europe/Warsaw");
setlocale(LC_ALL, en_GB);
$year = strftime('%Y');
$month = strftime('%m');
$day = strftime('%e');
//$hour = strftime('%k');
if($month < 10)
{
$month = substr($month,1);
}
$argsi = array(
'numberposts' => 1,
'post_type' => 'koncerty',
'orderby' => 'date',
'order' => 'ASC',
'date_query' => array(
'after' => array(
'year' => $year,
'month' => $month
),
'inclusive' => 'true'
)
);
$recent_post = wp_get_recent_posts($argsi, ARRAY_A);
the problem is, when I'm trying to inlude the day to the array
$argsi = array(
'numberposts' => 1,
'post_type' => 'koncerty',
'orderby' => 'date',
'order' => 'ASC',
'date_query' => array(
'after' => array(
'year' => $year,
'month' => $month,
'day' => $day
),
'inclusive' => 'true'
)
);
the code stopped working and I don't know why. I tried $day = strftime('%d')
and then remove 0 in it if day < 10, but still nothing :/