Best way to skip first x posts in a loop

I want to show the first four posts for a loop with a large format, then have a second loop that shows the remaining posts in list form, paginated by 8. What is the most efficient way to skip the first four posts in that second loop? The loops are in order by date.

Hmm, this should be easy but there is no ‘offset’ parameter for the loop from what I can tell.

Maybe you can adapt the logic outlined here to count the number of posts and return the ones you want:
https://docs.loopsandlogic.com/156/how-to-make-a-loop-behave-differently-every-nth-item-eg-display-content-every-third-post-change-styling-on-evenodd-posts?category_id=8

1 Like

Yes, an offset for loops is missing.

You can use loop count in combination with <If>.

1 Like

Thanks. For now I have given this post type a field called order and this works:

  <If check='{Field order}' more_than value='{Get local=voffset}'>
1 Like

You were the one that originally requested this, but for the sake of others in this thread I figured I’d mention that there’s a feature request here that’s planned. Not sure what the timing is going to be on its release, but it’s on the roadmap.

That seems like a lot of manual effort to manage that custom order field unless you need it for another purpose! Personally, the way I’d do it in your case would be to display the first four featured posts (or whatever number you set in your variable) using something like this:

<Loop type=something count='{Get local=voffset}'>

And then the remaining ones could be offset by the same amount with something like this:

<Loop type=something>
  <If check='{Get loop=count}' more_than value='{Get local=voffset}'>

The downside to any of the solutions proposed in this thread is that pagination won’t work quite right because the filtering is happening after the loop is set (it’s happening within the loop with that If tag). The only way to get this to work exactly as you’ve described with the remaining posts appearing paginated with eight posts per page would be through an offset attribute in the Loop tag. Hopefully the devs can get to that soon!

2 Likes

Another way to do this is to create a variable with all already displayed id’s and to exclude these in the loop. Bit hacky but the pagination works.

2 Likes