Created
March 28, 2024 18:10
-
-
Save nathaningram/655222f9734fd84aa274a1d3b13e4e53 to your computer and use it in GitHub Desktop.
Sort Kadence Post Grid by Post Meta
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
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