Pagination For Looper Provider Plus

Hi,

I am currently investigating the most effective strategies for implementing pagination with ACF looper providers. I came across other threads available in the Forum on the subject, including Twig Example: Pagination for Looper Providers (finally!).

This solution is effective as long as Meta Values are not utilized to filter Looper items. Othervise, there are still a few challenges I am facing.

  1. I have two sections in the events calendar with Coming Events (green headline) and Past Events (grey headline). Their Looper Providers vary only by Meta Values, which I use to compare the current date with the event’s start and/or end dates and Order by settins. Since there are fewer upcoming events compared to the past events looper, I need pagination only for the last.
    It seams like using the Offset Code from the thread mentioned above counts all events in the looper, ignoring the Meta Values I set. The {{ looper.count }} key in the past events header works correctly and outputs the fact number of filtered looper items per page taking into account Meta Values used in the Query Builder. The Pagination Element displays 4 pages instead of the required 3 for national events, including some looper items that should be excluded by Meta Values. How to get rid of those looper items which should be ignored inside Pagination?

  2. At the main Events Page where I show all upcoming events paginations looks even more confusiong and doesn’t work at all returning 404 error.

  3. Clicking any pagination button in the Coming Events section should switch to the next page and scroll down to the Past Events section using its ID in my case. Is there a way to add #ID to the pagination element URL so it would be added at its very end? If not, what could be a workaround? Should I make custom pagination buttons to get that option instead of using the native CS Post Pagination Element?

Pagination looks good for the 2025 taxonomy only because all events listed there in the past, with no separation between upcoming and past events.