Query 2 Post types?

I’ve tried 2 ways to accomplish this but perhaps I approaching it wrong? I was thinking I could create my own custom ajax search bar that searches 2 custom post types I have.

I can query my 2 post types and return the correct data back to bricks, BUT I am unable to use the LIVE search of my query loop. Is there a way to enable the Live Search panel?

Here is the code from: Adding any Custom WP_Query loop to Bricks' Query Loop - BricksLabs

<?php

//// Code 
////https://brickslabs.com/adding-any-custom-wp_query-loop-to-bricks-query-loop/

/* Add new query type control to query options */
add_filter( 'bricks/setup/control_options', 'bl_setup_query_controls');
function bl_setup_query_controls( $control_options ) {
    /* Adding a new option in the dropdown */
    $control_options['queryTypes']['my_vendor_show_query'] = esc_html__( 'My Custom Query' );
  return $control_options;
};

/* Run new query if option selected */
add_filter( 'bricks/query/run', 'bl_maybe_run_new_query', 10, 2);
function bl_maybe_run_new_query( $results, $query_obj ) {
    if ( $query_obj->object_type !== 'my_vendor_show_query' ) {
	    return $results;
    }
    /* If option is selected, run our new query */ 
    if ( $query_obj->object_type === 'my_vendor_show_query' ) {
        $results = run_new_query();
    }
    return $results;
};

/* Setup post data for posts */
add_filter( 'bricks/query/loop_object', 'bl_setup_post_data', 10, 3);
function bl_setup_post_data( $loop_object, $loop_key, $query_obj ) {
    if ( $query_obj->object_type !== 'my_vendor_show_query' ) {
	    return $loop_object;
    }
     global $post;
     $post = get_post( $loop_object );
     setup_postdata( $post );
     return $loop_object;
};

/* Return results from our custom WP Query arguments */
function run_new_query() {
    // Get the current date in YYYYMMDD format
    $today = date('Ymd');
    // First query: show-listing with date constraint, ordered by `show_start_date`
    $show_listing_args = array(
        'post_type'      => 'cutumpost1',
        'posts_per_page' => 5, // Up to 5 show-listing posts
        'post_status'    => 'publish',
        'meta_query'     => array(
            array(
                'key'     => 'show_start_date',
                'value'   => $today,
                'compare' => '>=', // Only include dates from today onward
                'type'    => 'DATE'
            ),
        ),
        'orderby'        => 'meta_value', // Order by show_start_date
        'meta_key'       => 'show_start_date', // Specify the key for ordering
        'order'          => 'ASC' // From soonest to latest upcoming events
    );
    $show_listing_query = new WP_Query($show_listing_args);

    // Second query: vendor posts, ordered by post date
    $vendor_args = array(
        'post_type'      => 'cutumpost2',
        'posts_per_page' => 5, // Up to 5 vendor posts
        'post_status'    => 'publish',
        'orderby'        => 'date', // Order by post date
        'order'          => 'DESC' // Newest first
    );
    $vendor_query = new WP_Query($vendor_args);

    // Combine both sets of posts (up to 5 each, so total up to 10)
    $combined_posts = array_merge($show_listing_query->posts, $vendor_query->posts);

    // Create a new WP_Query object to hold the combined posts
    $combined_query = new WP_Query();
    $combined_query->posts = $combined_posts;

    // Reset post data after each query
    wp_reset_postdata();

    // Return the combined WP_Query object
    return $combined_query->posts;
};

My second approach was to try and use Bricks Query editor. Example below, but I want to query only 5 results from each post type. Does anyone have any experience with this?

return [
    'post_type'      => ['show-listing', 'vendor']
];

When I tried to use add_filter( ‘bricks/setup/control_options’)… the issue with this is that you end up unable to use the live search as far as I can tell. But it can work if you don’t need live search.

SOLUTION add_filter( 'bricks/query/result): Played around with it, tried different things, but I think I got it work. In bricks create your live search and just add the 2 Posts and complete your setting as you like…… then use this filter to manipulate the returned results.

Here’s my code snippet, works good so far:

add_filter( 'bricks/query/result', function( $result, $query_obj ) {
	
		//error_log( print_r( $result, true ) );
		//return $result;
	 if ( $query_obj->element_id !== 'qiidxf' || $query_obj->object_type !== 'post' ){
		    return $result;
	  }
...
...
...  //manipuate the  result here. to your desired needs.  
...
		// Important Update post count and found posts based on the modified posts array. 
		$result->post_count = count( $result->posts );
		$result->found_posts = $result->post_count;    
		//error_log( print_r( $result->posts, true ) );
    return $result;    
}, 10, 2 );