Body: <p>I want to create a basic product listing page based on categories. I created a template that dynamically shows all items based on the category that is passed to it <a href="https://craftcms.stackexchange.com/questions/37007/paginate-based-on-items-in-a-category">based on the help I received here</a>. That solution works great, but I'm getting the <a href="https://craftcms.stackexchange.com/questions/35244/looping-through-element-queries-directly-has-been-deprecated">Deprecation warning</a> others have received: <em>Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them.</em></p>
  <p>Here is my solution that works, but throws the deprecation:</p>
  <pre><code>{% set query = craft.entries()
      .section('mySection')
      .relatedTo(category)
      .limit(10)
  %}
  
  {% paginate query as pageInfo, pageEntries %}
  
  {% for entry in pageEntries %}
       &lt;p&gt;&lt;a href=&quot;{{ entry.url }}&quot;&gt;{{entry.title}}&lt;/a&gt;&lt;/p&gt;
  {% endfor %}
  
  {% if pageInfo.prevUrl %}&lt;a href=&quot;{{ pageInfo.prevUrl }}&quot;&gt;Previous Page&lt;/a&gt;{% endif %}
  {% if pageInfo.nextUrl %}&lt;a href=&quot;{{ pageInfo.nextUrl }}&quot;&gt;Next Page&lt;/a&gt;{% endif %}
  </code></pre>
  <p>I've looked through all the questions and answers here, and gone back to the documentation on pagination, <a href="https://craftcms.com/docs/3.x/dev/tags.html#paginate" rel="nofollow noreferrer">which still uses limit()</a>, <strong>but I can't figure out how I can paginate if I'm not able to use limit() and instead have to use all()?</strong></p>
  <p>I'm new to Craft so it's entirely possible I'm missing something simple.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-22T07:04:03.780Z
Comments.Text: This should work. Are you sure the warning isn't left over from a previous attempt? If you clear it in the control panel then refresh your page, does it come back? Any other query on the page?
Comments.UserDisplayName: Oli
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-22T22:50:19.600Z
Comments.Text: I cleared it (which I didn't realize I could do) and it does seem fine. I was thrown by the various posts (and error) that said all() was needed. Thanks.
Comments.UserDisplayName: doctorgloom
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-12T15:40:35.703Z
Comments.Text: I'm still facing the same issue with this pagination syntax. Even after clearing the deprecation error, it surfaces again after awhile. Any tips?
Comments.UserDisplayName: HG Tan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-12T21:29:02.057Z
Comments.Text: @HGTan sorry, but unfortunately I don't have any tips. For me it was fine after clearing errors, and I'm still relatively new with Craft. Maybe check if you have any other queries on the page that could be causing it.
Comments.UserDisplayName: doctorgloom
Tags: <categories><error-message><pagination><deprecation>
Title: How do you Paginate if Looping through element queries directly is deprecated?
ThreadText: # How do you Paginate if Looping through element queries directly is deprecated?
  
  (Asked by: username_0 on 2021-01-21)
  
  I want to create a basic product listing page based on categories. I created a template that dynamically shows all items based on the category that is passed to it [based on the help I received here](https://craftcms.stackexchange.com/questions/37007/paginate-based-on-items-in-a-category). That solution works great, but I'm getting the [Deprecation warning](https://craftcms.stackexchange.com/questions/35244/looping-through-element-queries-directly-has-been-deprecated) others have received: *Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them.*
  
  Here is my solution that works, but throws the deprecation:
  
  ```
  {% set query = craft.entries()
      .section('mySection')
      .relatedTo(category)
      .limit(10)
  %}
  
  {% paginate query as pageInfo, pageEntries %}
  
  {% for entry in pageEntries %}
       <p><a href="{{ entry.url }}">{{entry.title}}</a></p>
  {% endfor %}
  
  {% if pageInfo.prevUrl %}<a href="{{ pageInfo.prevUrl }}">Previous Page</a>{% endif %}
  {% if pageInfo.nextUrl %}<a href="{{ pageInfo.nextUrl }}">Next Page</a>{% endif %}
  
  ```
  
  I've looked through all the questions and answers here, and gone back to the documentation on pagination, [which still uses limit()](https://craftcms.com/docs/3.x/dev/tags.html#paginate), **but I can't figure out how I can paginate if I'm not able to use limit() and instead have to use all()?**
  
  I'm new to Craft so it's entirely possible I'm missing something simple.
  
  **Tags:** categories, error-message, pagination, deprecation
  
  > **Comments:**
  > **username_1**: This should work. Are you sure the warning isn't left over from a previous attempt? If you clear it in the control panel then refresh your page, does it come back? Any other query on the page?  
  > **username_0**: I cleared it (which I didn't realize I could do) and it does seem fine. I was thrown by the various posts (and error) that said all() was needed. Thanks.  
  > **username_2**: I'm still facing the same issue with this pagination syntax. Even after clearing the deprecation error, it surfaces again after awhile. Any tips?  
  > **username_0**: @username_2 sorry, but unfortunately I don't have any tips. For me it was fine after clearing errors, and I'm still relatively new with Craft. Maybe check if you have any other queries on the page that could be causing it.  
  
  ---
  
  ## 0 answers
  
  