-
-
Save thisbit/9907105ab7df17f4362ac90706d37d49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// GenerateBlocks variant of pre_get_posts for the query block | |
add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) { | |
if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'custom-grid-class' ) !== false ) { | |
$query_args['meta_key'] = 'field_name'; | |
$query_args['orderby'] = 'meta_value'; // better for strings | |
// $query_args['orderby'] = 'meta_value_num'; // better for numbers | |
$query_args['order'] = 'ASC'; | |
} | |
return $query_args; | |
}, 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment