How to use alternate post layout at key points in post loop?

There are a number of ways you can break this up. I think you have the right idea though to break it inside of your current loop with $i, but maybe something simple that is readable could be changing this:

if ($i == 19 OR $i == 31 OR $i == 43) { ?>

Into this:

if(
    in_array($i, range(19, 21)) ||
    in_array($i, range(31, 33)) || 
    in_array($i, range(43, 45))
) { ?>

You could take it a deeper and create an array that could control the number you want to start with and an offset of that number to be flagged as a Featured post.

Hope this helps!!

Leave a Comment