Try to get two different arrays of posts and loop through array A. Before get post data of A element get random element from array B.
For example:
$array_a = ['post_id_a1', 'post_id_a2', 'post_id_a3'];
$array_b = ['post_id_b1', 'post_id_b2', 'post_id_b3'];
foreach ( $array_a as $a_post_id ) {
$is_b_should_displayed = mt_rand( 0, 1 );
if ( $is_b_should_displayed && $b_length = count( $array_b ) ){
$b_to_show = mt_rand( 0, $b_length - 1 );
// show random B post
unset( $array_b[ $b_to_show ] );
$array_b = array_values( $array_b ); // to reorder array after unset
}
// show A post
}
Or in same way create array C, and then loop through C to display posts.
There is no warranty all B will displayed, so, if you need it, you could loop through B (if at least 1 element exist) after main A loop
Small note: rand
using for key orderby
not to order according to wp docs.
Hope it helps