Use a meta query. Since ACF stores dates as Ymd
you can just treat the value as a number:
$date_query = array(
'key' => 'start_date', // ACF date field name
'type' => 'NUMERIC',
'value' => '20200101',
'compare' => '<=', // All posts with start date before/on January 1st 2020
);
$args['meta_query'] = array( $date_query );
Any typical comparison e.g. =
, !=
, >
, >=
, <
, <=
can be used for the value of compare
.
Or perhaps a date range is what you need e.g. to get all posts for December 2019:
$date_query = array(
'key' => 'start_date',
'type' => 'NUMERIC',
'value' => array( '20191201' /* Start date */, '20191231' /* End date */ ),
'compare' => 'BETWEEN',
);
Here’s an (untested) example for your question:
// Grab the current date for the set timezone
$currentDate = new DateTimeImmutable( current_time( 'mysql', true /* GMT */ ), new DateTimeZone( 'America/Edmonton' ) );
// Add fourteen days to the current date
// Use this variable in a loop to increment the total number of visible posts by one every 14 days
$datePlusFourteen = $currentDate->add( new DateInterval( 'P14D' ) );
$args = array(
'post_type' => 'sendouts',
'cat' => '101',
'order' => 'ASC',
'orderby' => 'p',
'meta_query' => array(
array(
'key' => 'sendout_start_date',
'type' => 'NUMERIC',
'value' => array( $currentDate->format( 'Ymd' ), $datePlusFourteen->format( 'Ymd' ) ),
'compare' => 'BETWEEN',
),
),
);
$query = new WP_Query( $args );