<div class="row">
<?php
$mainpost = get_posts( array(
'numberposts' => 3,
'meta_query' => array(
array(
'key' => 'show_in_main',
'value' => '1',
)
)
) );
foreach( $mainpost as $post ) { ?>
<div class="col-8">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
</div>
<div class="col-8"></div>
<div class="row">
<div class="col-12">второй пост</div>
<div class="col-12">третий пост</div>
</div>
<?php foreach( $mainpost as $i => $post ) { ?>
<?php if ($i == 1): ?>
<div class="row">
<?php endif; ?>
<?php if ($i == 0): ?>
<div class="col-12">
<?php else: ?>
<div class="col-8">
<?php endif; ?>
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
</div>
<div class="row">
<div class="col-12">
<?php foreach( $mainpost as $i => $post ): if ($i == 0):?>
<?php the_post_thumbnail(); break; ?>
<?php endif; endforeach; ?>
</div>
</div>
<div class="col-8">
<?php foreach( $mainpost as $i => $post ): if ($i > 0): ?>
<?php the_post_thumbnail(); ?>
<?php endif; endforeach; ?>
</div>