Skip to content

Instantly share code, notes, and snippets.

@codysmith44
Last active November 23, 2024 18:20
Show Gist options
  • Save codysmith44/a072cdef9f87d68494bac7d900c8fe5d to your computer and use it in GitHub Desktop.
Save codysmith44/a072cdef9f87d68494bac7d900c8fe5d to your computer and use it in GitHub Desktop.
<?php
add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
// Add a custom class to the "grid" item. Need to double check and see if that's still the case for GB 2.0
if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'custom-class-here' ) !== false ) {
$custom_args = array(
// list of custom arguments
'orderby' => 'title',
'order' => 'ASC'
);
return array_merge( $query_args, $custom_args );
}
return $query_args;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment