Increase offset while looping

Yup. What you’re looking for is a smart “counter”. In actuality, your issue is this: You’re trying to avoid duplicate posts. Here’s the popular method to do it. In every file that you run a query, you must add this code: global $duplicated_posts; $args = [ ‘post_type’ => ‘post’, ‘post__not_in’ => $duplicated_posts ]; $query = … Read more

Order by empty custom field

There are two solutions for that: 1. Make sure that all posts have that field set. You can do this easily – just use save_post hook and set it to default value. (You should also add default values for already existing posts that don’t have that field set.) 2. Use a little bit modified query … Read more

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