I would like to query WordPress draft posts only from the past 7 days (ie current date and looking back at the last 7 days, not looking at strictly Monday to Sunday weeks).
The problem I am facing at hand is that it does not return me any results at all. If I were to comment out the line that specifies the post_status, it works on published posts only.
EDIT: Problem is resolved. The issue at-hand causing no results to show up was pertaining to other parts of my code.
EDIT2: The code below can be significantly shortened to:
'date_query' => array( array( 'after' => '1 week ago' )
My original code is as follows:
$today = getdate(); $args = array( 'post_type' => array('post', 'page'), 'post_status' => 'draft', 'posts_per_page' => '-1', 'date_query' => array( array( 'after' => array( 'year' => $today['year'], 'month' => $today['mon'], 'day' => ($today['mday'] - 7) ), 'before' => array( 'year' => $today['year'], 'month' => $today['mon'], 'day' => $today['mday'] ), 'inclusive' => true ) ) );