Never re-do the main query. Hook into pre_get_posts
and change it. The following needs to go in your functions.php
(putting in the template will mean it runs too late):
add_action( 'pre_get_posts', function ( $wp_query ) {
if ( $wp_query->is_main_query() && $wp_query->is_tag() ) {
$wp_query->set( 'posts_per_page', 20 );
$wp_query->set( 'post_type', [
'pavilion',
'post',
'catalog',
'tenders',
'services',
]);
}
});
And now your template code should just be:
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
// your code!
}
}