Skip to content

Instantly share code, notes, and snippets.

@dcooney
Last active March 2, 2023 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcooney/78e65720ca993e9204469c3a09b881c8 to your computer and use it in GitHub Desktop.
Save dcooney/78e65720ca993e9204469c3a09b881c8 to your computer and use it in GitHub Desktop.
Order Ajax Load More results by custom meta_query clause.
<?php
// @see https://connekthq.com/plugins/ajax-load-more/docs/filter-hooks/#alm_query_args
function my_filter_args( $args, $id ){
// [ajax_load_more id="my_alm_id"]
// Custom meta query clause.
$datum_clause = [
'key' => 'datum',
'value' => date("Ymd"),
'compare' => '>=' ,
'type' => 'DATETIME'
];
// Add to meta_query.
$args['meta_query']['datum_clause'] = $datum_clause;
// Add custom ordering.
$args['orderby'] = [
'datum_clause' => 'ASC',
];
return $args;
}
add_filter( 'alm_query_args_my_alm_id', 'my_filter_args', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment