Despite using null and paginate false i can still only return 100 queries with this:

{% set results = craft.entries({
    limit: null,
    paginate: false,
    section: 'directory',
    relatedTo: relationParam
}) %}

How do I get all of them?


Well I found the problem and solution which is a bit strange - makes no sense to me. I am passing relatedTo a merged string 'relationParam' which has the mulitpple categories I want to search for. Once I set the limits on the categories that are related to the entries -see below - it all works.

{% set c = craft.categories.group('locations').slug(countrySlug).limit(null) %}
{% set p = craft.categories.group('locations').slug(portSlug).limit(null) %}

So what doesn't make sense to me is that I am having to set the limit outside of the main entries query. I would have thought the entry limit specification would do this not on the categories related.

  • 2
    There isn't a paginate parameter, so you can safely remove that. Maybe you just happen to have exactly 100 related entries? – Brad Bell Nov 11 '16 at 18:32
  • Nah I am expecting 410. I am outputting a count on screen of the results array and its always 100 – joomkit Nov 12 '16 at 8:28
  • What happens if you set the limit parameter to 410? How do you know that there should be 410 entries? – Mats Mikkel Rummelhoff Nov 13 '16 at 11:04
  • If I set the limit to 500 I still get just a 100 records returned. If I take out the 'relatedTo' params ( my search query) then I get my 410 records. It seems that relatedTo params is enforcing a limit – joomkit Nov 14 '16 at 10:07

The reason this happens is Craft has a default limit of 100 for all ElementCriteriaModel objects (this includes assets, categories, entries, tags, and users, also relations as you encountered).

This isn't made terribly clear in the documentation, but you can see it under the defineAttributes() method on the ElementCriteriaModel class reference page.

As you discovered, adding a .limit(null) parameter overrides that limit.

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.