Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Created March 28, 2024 18:10
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 nathaningram/655222f9734fd84aa274a1d3b13e4e53 to your computer and use it in GitHub Desktop.
Save nathaningram/655222f9734fd84aa274a1d3b13e4e53 to your computer and use it in GitHub Desktop.
Sort Kadence Post Grid by Post Meta
add_filter( 'kadence_blocks_pro_posts_grid_query_args', 'sort_by_date_post_grid_order',10, 2 );
function sort_by_date_post_grid_order( $args, $attributes ) {
if ( 'POST_TYPE_SLUG_HERE' === $args['post_type'] && isset($attributes['className']) && strpos($attributes['className'], 'BLOCK_CLASS_HERE') !== false ) {
$args['meta_key'] = 'start_date';
$args['orderby'] = 'meta_value';
$args['order'] = 'ASC';
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment