Skip to content

Instantly share code, notes, and snippets.

@topher1kenobe
Created July 31, 2024 21:57
Show Gist options
  • Save topher1kenobe/1acfe1faec57d73de0b3b086138713fa to your computer and use it in GitHub Desktop.
Save topher1kenobe/1acfe1faec57d73de0b3b086138713fa to your computer and use it in GitHub Desktop.
Adjusting the Advanced Query Loop from Kadence via code.
add_filter( 'kadence_blocks_pro_query_loop_query_vars', 'hba_home_events_loop', 10, 3 );
function hba_home_events_loop( $query, $ql_query_meta, $ql_id ) {
if( 265 === $ql_id ) {
$meta_query = array(
array(
'key' => 'hba_event_beginning', // your event meta here
'value' => date('Y-m-d H:m'),
'type' => 'DATETIME',
'compare' => '>=' // only show dates matching the current date or in the future
)
);
$query['posts_per_page'] = 3; // show all posts
$query['meta_query'] = $meta_query;
$query['post_status'] = 'publish';
$query['post_type'] = 'event';
$query['order'] = 'ASC'; // sort showing most recent date first
$query['orderby'] = 'meta_value';
$query['meta_key'] = 'hba_event_beginning';
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment