At the moment I create a new page, set a featured image and link a certain CPT template to show all those CPT's (by using a query) with the featured image on top. However, this is in my opinion the wrong way to do this because each time I create a new CPT I'll have to create a new template. My page types now look like "default, cases, products, clients, ..." which is not the purpose of a template.
I tried using archive-CPT.php which will automatically loop through the correct CPT but the problem is that I can't use a featured image anymore. I could, but I want to change/remove/add the image via Wordpress like I do with pages...
How would I be able to achieve this the right way?
<?php while( have_posts() ) : the_post(); $header = get_the_post_thumbnail_url(); $title = get_post_meta(get_the_ID(), 'page_title', true); $subtitle = get_post_meta(get_the_ID(), 'page_subtitle', true); ?> <header class="page-header about-header" style="background-image:url(<?php echo $header; ?>)"> <h1 class="page-hero-title"><?php echo $title; ?></h1> <h2 class="page-hero-subtitle"><?php echo $subtitle; ?></h2> </header> <?php endwhile; while( have_posts() ) : the_post(); ?> <div class="row clients"> <?php while( have_posts() ) : the_post(); ?> <h1><php the_title(); ?></h1> <?php endwhile; ?> </div> <?php get_footer(); ?>