I will have around 5 custom post types on a new site. I am looking for an efficient way to display these post types on one (index) page, assigning a different template / style to each one (for example one post type might need a featured image, others might be quotes etc.)
This older post response by danblaker looks like it is doing exactly the right thing without needing to write five or more loops for one page, but being fairly new to WP I cannot see exactly how and where to apply it or indeed if this is even possible still!
So far I can display a given post type one at a time on the index page and I can assign a specific template to this post type one at a time like so —
$args = array( 'post_type' => 'atoz_key', 'posts_per_page' => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); get_template_part( 'template-parts/atoz_key', get_post_format() ); endwhile;
ABOVE the main index loop, but doing this 5+ separate loops seems bit daft!
Dan's solution seems much more elegant but I cannot see how exactly to implement!
Any help much appreciated.