Pagination in custom query

Hi again Theme.co Team,

I’ve got another question about how to make pagination work if query builder or custom query along with CS Forms filters are used to loop through CPT content?

If I add a Pagination Element it reflects the correct amount of pages based on the real amount of items but the buttons don’t really work. Should I add some Custom Attribute to that pagination element and/or maybe to Looper Provider custom JSON?

Hello John,

Thanks for writing in!

In Pro Theme’s Layout Builder, an Archive template type is designed to work with the main WordPress query – the same query that WordPress uses to determine which posts/products appear on the page. The built‑in Pagination element expects to operate on that main query.

When you add a Looper Provider (e.g., a custom WP_Query), you are replacing that main query with your own. The Pagination element, however, still looks at the global $wp_query object, which no longer reflects your custom loop. That’s why the “total pages” number is correct (the element reads the provider’s max_num_pages) but the links don’t work – they are pointing to the next page of the main query, not your custom one.

At the same time, your Looper Provider disconnects the functionality of the CS Form Filter. It is highly advisable to disable the Looper provider.

Kindly let us know how it goes.

Hew Rue,

The problem with the Events Archive is that I need a custom sorting by one of ACF fields which is event_start_date assending. Will it be the same thing if I use custom Query String instead? What can be a workaround?

Thank you in advance.

Hello John,

My strong recommendation is to disable the Looper Provider altogether and work with the main query instead. You can still achieve everything you need – including custom sorting, filtering, and even complex meta queries – by hooking into pre_get_posts .

This is exactly the approach we took in the older “Super Loopers – Custom Events Page” thread, where we used pre_get_posts to filter events by an ACF date field and order them in ascending. That way, pagination, filters, and everything else just works out of the box because the main query stays intact.

Kindly let us know how it goes.

Rue, thank you for this reference.

I will definitely check that out to give it a try.

You are most welcome, John