I’ve found old pieces of code and joined it with yours. It could be more elegant, but you have the idea.
<?php
$args = array(
'category__not_in' => array( 20 ),
);
$query = new WP_Query( $args );
$posts = $query->posts;
wp_reset_postdata();
$post_counter = 1;
// secondary posts' categories (ids)
$sec_categories = [2, 14, 56, 234];
$cat_counter = 0;
foreach( $posts as $post ) {
echo '<h1>' . $post->post_title . '</h1>';
echo '<p>' . $post->post_excerpt . '</p>';
// after each 3rd post goes (two) secondary
if( $post_counter % 3 == 0 ) {
query_posts( 'cat=" . $sec_categories[$cat_counter] . "&posts_per_page=2' );
while ( have_posts() ) {
the_post();
echo '<h2>' . get_the_title() . '</h2>';
echo '<p>' . get_the_excerpt() . '</p>';
}
wp_reset_query();
$cat_counter++;
}
$post_counter++;
}
You have to think out how to choose categories for secondary posts