Why not just do straight what you’ve wanted.
<?php
$args_one = array(
'cat' => 7,
'posts_per_page' => 8,
);
$args_two = array(
'cat' => 10,
'posts_per_page' => 8,
);
// will run 2 sql queries.
$posts_one = get_posts( $args_one );
$posts_two = get_posts( $args_two );
$all_posts = array();
// lets merge them into 1 array.
while ( isset( $posts_one[0] ) || isset( $posts_two[0] ) ) {
if ( isset( $posts_one[0] ) ) {
$all_posts[] = array_shift( $posts_one );
}
if ( isset( $posts_two[0] ) ) {
$all_posts[] = array_shift( $posts_two );
}
}
/**
* Now we've merged them gracefully into 1 array regarless of if these arrays are equal in size or not.
* so we can now render them in single loop.
*/
if ( count( $all_posts ) ) :
$num = 1;
global $post;
foreach ( $all_posts as $post ) :
setup_postdata($post);
if ( 0 === $num % 2 ) {
get_template_part( 'mobile-template/loop-even' ); // i've added suffix -even|-odd to make it possible to render them a bit differently.
} else {
get_template_part( 'mobile-template/loop-odd' );
}
$num++;
endforeach;
wp_reset_postdata();
endif;