<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php the_posts_pagination(); ?>
<?php else : ?>
<p><?php esc_html_e( 'Sorry, no posts matched your criteria.', 'text-domain' ); ?></p>
<?php endif; ?>
Only the loop part for an archive template. Standardized approach, uses only default available functions and core post type data. Extend it to add custom fields in an archive targeting a single post type.