GenerateBlocks 2.0 is here - Read the release post

Learn GenerateBlocks

generateblocks_query_wp_query_args

apply_filters(
    'generateblocks_query_wp_query_args',
    $args,
    $attributes,
    null === $block ? new stdClass() : $block,
    [
        'post_id'   => $current_post_id,
        'author_id' => $current_author_id,
    ]
);

Description

Filter the wp_query $args for the Post Query Block.
Attached to the Query Block wp:generateblocks/query

Params

$args – the wp_query_args
$attributes – the block attributes

Basic Example #1

Order by date meta query.
Application: Add order-by-date to the Query Block classes

add_filter( 'generateblocks_query_wp_query_args', function( $args, $attributes ) {
    if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'order-by-date' ) !== false ) {
        $args = array_merge( 
            $args, 
            [
                'meta_key'  => 'date_from',
                'meta_type' => 'DATE',
                'orderby'   => 'meta_value',
                'order'     => 'ASC',
            ]
        );
    }

    return $args;
}, 10, 2 );