Query posts using less than
How about something like this? $args = array( ‘date_query’ => array( array( ‘before’ => array( ‘year’ => 2013, ‘month’ => 2, ‘day’ => 28, ), ‘inclusive’ => true, ), ), ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); Obviously you could set the exact date from a variable. More info: https://codex.wordpress.org/Class_Reference/WP_Query