Supongo que usará argumentos en el ciclo.
Puede usar el bucle para agregar todos los post_id devueltos a una matriz. Puede ejecutar dos bucles separados y agregar todas las entradas a una matriz. Tendría que verificar si hay entradas dobles, para que no termine imprimiendo la misma publicación dos veces.
Así que harías algo como-
//First loop
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'orderby' => $ordering_args['orderby'],
'order' => $ordering_args['order'],
'posts_per_page' => apply_filters('yith_wcas_ajax_search_products_posts_per_page', get_option('yith_wcas_posts_per_page')),
'meta_query' => array(
array(
'key' => '_visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
),
)
);
while ( $loop->have_posts() ) : $loop->the_post();
$post_id = get_the_ID();
$my_post = my_post_function($post_id);
//Store the items in an array
$my_post_array [] = $my_post;
query_posts($args);
endwhile;
//Second loop
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'orderby' => $ordering_args['orderby'],
'order' => $ordering_args['order'],
'posts_per_page' => apply_filters('yith_wcas_ajax_search_products_posts_per_page', get_option('yith_wcas_posts_per_page')),
'meta_query' => array(
array(
'key' => '_sku',
'value' => apply_filters('yith_wcas_ajax_search_products_search_query', $search_keyword),
'compare' => 'LIKE'
)
)
);
while ( $loop->have_posts() ) : $loop->the_post();
$post_id = get_the_ID();
$my_post = my_post_function($post_id);
//Store the items in an array
$my_post_array [] = $my_post;
query_posts($args);
endwhile;
//Remove duplicate entries from the array
array_unique ( $my_post_array, SORT_STRING );