DocumentationOnline documentation for Ajax Load More
Date Query
Ajax Load More does not integrate directly with the WP_Date_Query class, however, we can use the alm_query_args filter to extend the Ajax Load More query to include a custom date query.
The code sample below will query posts between March 1, 2020, and January 1, 2019, using a WP_Date_Query.
<?php
// [ajax_load_more id="date_query_example"]
function my_date_query_example( $args, $id ){
$args['date_query'] = array(
'relation' => 'AND',
array(
'before' => array(
'year' => 2020,
'month' => 3,
'day' => 1
),
),
array(
'before' => array(
'year' => 2019,
'month' => 1,
'day' => 1
),
)
);
return $args;
}
add_filter( 'alm_query_args_date_query_example', 'my_date_query_example', 10, 2);
PHP