Last active
March 2, 2023 16:01
-
-
Save dcooney/78e65720ca993e9204469c3a09b881c8 to your computer and use it in GitHub Desktop.
Order Ajax Load More results by custom meta_query clause.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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