Template structure

You said you’re in a custom loop that returns various post_types: //….. while ( $loop->have_posts() ) : $loop->the_post(); get_template_part($post->post_type,’layout’); endwhile; in this way you don’t use extra conditionals and relying on get_template_part() you simply need different files post_type1-layout.php , post_type2-layout.php, etc.. in the root folder of your theme / child theme keeping the templates separate, … Read more