I have a list of entries, with an option to filter them by categories.

If no filter is applied, clicking an entry should (and does) take you to the permalink URL for that entry, as defined in the section settings:

<a href="{{ entry.url }}">{{ entry.title }}</a>

Results in:

<a href="/beverages/gin">Gin</a>

However, if a filter is applied, I'd like to "remember" the category, and apply it to the entry's {{ entry.getNext() }}-style pagination.

In other words, imagine a "Consumables" section, with entries of "Gin", "Lasagne", "Noodles", & "Vodka" (with the obvious categories of "Beverages" and "Food"). You filter the entries on the listing page by the "Beverages" category, & click on the "Gin" entry therein. What I want is for the "Next Entry" link on Gin's page to go to "Vodka", not "Lasagne".

So far, the solution I came up with is to modify the URL for when entries are filtered so that the applied filter results in a URL of /consumables/category/beverages. I also have a route set up so that when a fourth segment is present, it tries to match it up with an entry, eg. /consumables/category/beverages/gin.

Now, I don't know if this is the best solution for this issue, but if it is, the remaining problem is figuring out how to modify the links to the entries on filtered pages so that they include the category. Something like {{ entry.url('consumables/category/' ~ entry.category) would be nice, but it doesn't seem to work like that.

  • Send it with a query param and check if there is a set query param when page is opened.
    – Maverick
    Jan 27, 2020 at 21:21
  • @Maverick I.... you know how sometimes your brain sees the answer clear as day right in front of you? Yeah, that wasn't me yesterday. Thanks!!
    – Sandwich
    Jan 28, 2020 at 9:19
  • Can you add your solution as an official answer?
    – Brad Bell
    Jan 30, 2020 at 0:48

1 Answer 1


So, the solution, as provided by @Maverick in their comment above, is just to pass the variable as a query param (?cat=foo), and check for that query param's value in the template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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