14

What’s the best way to paginate search results?

I was using

{% set query = craft.request.getParam('q') %}

and then

{% paginate craft.entries.search(query).section('…').limit(…).order('…') as entries %}

but the pagination links (paginate.prevUrl and paginate.nextUrl) don’t contain the query.

15

{{ paginate.nextUrl }}?q={{ query }} did the trick with this setup.

| improve this answer | |
2

I think this will work

{{ paginate.prevUrl }}?search=' ~ (craft.request.getParam('search'))
| improve this answer | |
  • Thanks. I used {{ paginate.nextUrl }}?q={{ query }} and that worked with my setup. – James Jul 1 '14 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.