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

How to show posts with multiple tags on tag.php?

get_query_var( ‘tag’ ) will return you ‘tag1+tag2+tag3’ string. get_query_var( ‘tag_slug__and’ ) will return you the array of tags. So, there are two ways to achieve the goal: $args = array( ‘tag’ => get_query_var( ‘tag’ ), // string ); or $args = array( ‘tag__and’ => get_query_var( ‘tag_slug__and’ ), // array ); It remains to be seen … Read more

WordPress loop: exclude if it is the latest post

If you create your own queries for these loops, all you have to do is to use post__not_in param in these queries. This way you will exclude given post from these loops. And to get the ID of first post, just use get_posts with ‘fields’ => ‘ids’

Duplicated posts on category page

OK, so the code does exactly what it is supposed to. In your archive.php you do this: while ( have_posts() ) : the_post(); get_template_part( ‘loops/loop’, ‘archive’ ); So for every post (both of them) you include loops/loop-archive.php file. And inside that file you don’t display only the current post from global loop, but you make … Read more