4

There seems to be a default limit to for loops in craft of 100.

I have a channel with quite a few entries.

How can I disable this without writing nasty things like .limit(100000000)

4
  • 1
    Does .limit(null) work?
    – joep
    Apr 1 '16 at 10:43
  • @user1463467 beat me to it, why not post as a real answer?
    – carlcs
    Apr 1 '16 at 10:44
  • 1
    Wasn't 100% sure and didn't want to lose my precious karma (I hate stackexchange with a passion).
    – joep
    Apr 1 '16 at 10:48
  • 1
    This question applies to Craft 2. As of Craft 3 there is no limit by default. Source: github.com/craftcms/cms/blob/develop/…
    – Ben Croker
    Jul 21 '20 at 17:57
3

As of Craft 3, there is no limit by default.

Per the CHANGELOG:

Element queries are no longer limited to 100 results by default.

(Credit to Ben Croker who originally added this answer as a comment above. Adding this here as it would be better as the upvoted answer.)

13

Set the limit to null limit(null).

2
  • This answer applies to Craft 2. As of Craft 3 there is no limit by default so setting limit to null is not necessary unless trying to override a previously set value. Source: github.com/craftcms/cms/blob/develop/…
    – Ben Croker
    Jul 21 '20 at 17:58
  • @BenCroker - glad I wasn't the only one who read the latest Craft Link List and suddenly thought of the Jumanji meme of "What Year is it??" :) Jul 21 '20 at 18:38
1

There very definitely is a default limit of 100 and using .limit(null) will definitely override it. I know this because I recently had the same issue myself!

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.