Add multiple post types in one query loop

Currently, GB query loop block can only select 1 post type for the query loop, if you want to add multiple post types in one query loop block, you can use the below method.

1. Add a CSS class to the Query loop block

Add a CSS class to the Grid block of the Query loop block.

2. Use generateblocks_query_loop_args to merge queries

The below code adds post/page/cpt-1/cpt-2 to the query loop block, you can change 'post', 'page', 'cpt-1', 'cpt-2' to your own post type slugs.

add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
	if ( 
        ! is_admin() &&
        ! empty( $attributes['className'] ) && 
        strpos( $attributes['className'], 'advanced-query' ) !== false
	) {
        // pass meta_query parameter
        $query_args[ 'post_type' ] = array('post', 'page', 'cpt-1', 'cpt-2');
	}
	
	return $query_args;
}, 10, 2 );

Adding PHP: https://docs.generatepress.com/article/adding-php/