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)

Brad Bell
  • 67,440
  • 6
  • 73
  • 143
KSPR
  • 3,786
  • 2
  • 29
  • 52

3 Answers3

13

Set the limit to null limit(null).

carlcs
  • 36,220
  • 5
  • 62
  • 139
  • 1
    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: https://github.com/craftcms/cms/blob/develop/CHANGELOG-v3.md#300---2018-04-04 – 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??" :) – Patrick Harrington Jul 21 '20 at 18:38
4

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.)

Ben Parizek
  • 13,448
  • 1
  • 33
  • 98
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!

Roi Agneta
  • 1,463
  • 2
  • 13
  • 21