I'm writing an on this day function which should show the X number of posts for the current day and month.
How can I add a fallback to the query if there are no posts, to show the next available day of posts?
These are the arguments I'm passing to the current day query.
$onThisDay_args = array(
'post_type' => array('on-this-day'),
'posts_per_page' => $postlimit,
'date_query' => array(
array(
'month' => date( 'n', current_time( 'timestamp' ) ),
'day' => date( 'j', current_time( 'timestamp' ) )
),
)
);
The only way I can think of executing this requirement is if the results from the first query equal null or 0, then run the second query.
If that is the case, how do I modify the date_query arguments to fallback to the previous day of available posts?
Thanks.