Multiple Post Types in Query Loop

Adding multiple Post Types to Query Loop:

add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
	if ( 
        ! is_admin() &&
        // if block has an advanced > additional CSS Class of: my-query
        ! empty( $attributes['className'] ) && 
        strpos( $attributes['className'], 'my-query' ) !== false
	) {
        // pass meta_query parameter
        $query_args[ 'post_type' ] = array('post', 'page');
	}
	
	return $query_args;
}, 10, 2 );
2 Likes