Answers.Body: <p>Recently i needed such thing again and this time i foud out how to do this:</p>
  <pre><code>{% set query = craft.entries %}
  
  {% set paginator = create('craft\\db\\Paginator', [query, {
      pageSize: 3,
      currentPage: craft.app.request.pageNum,
  }]) %}
  
  {% set pageInfo = create('craft\\web\\twig\\variables\\Paginate').create(paginator) %}
  
  {% set pageResults = paginator.getPageResults() %}
  </code></pre>
  <p>To manually set result page, you need to pass some number to <code>currentPage</code> instead of default value taken from URL. Note that initial query cannot have <code>limit</code> param, this needs to be passed as <code>pageSize</code> param to paginator class.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-10T15:00:08.070Z
Answers.Text: OMG that is so incredibly useful - I am building a Nuxt/Craft app and needed some api calls to paginate. It works perfectly. You are a champion! This should be marked as the answer.
Answers.UserDisplayName: bhu Boue vidya
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-17T11:53:07.457Z
Answers.LastActivityDate: 2021-10-17T12:21:43.117Z
Answers.LastEditDate: 2021-10-17T12:21:43.117Z
Answers.UserDisplayName: Piotr Pogorzelski
Answers.Body: <p>If you're looking to display a set of Elements that <em>simulate</em> a paginated query, you might actually be looking for the <code>offset</code> Query parameter.</p>
  
  <p>Here's an example of fetching a “page” of results based on a number of <code>entriesPerPage</code> and the number of <code>pagesToSkip</code>:</p>
  
  <pre><code>{% set customPageOfEntries = craft.entries()
      .offset(entriesPerPage * pagesToSkip)
      .limit(entriesPerPage)
      .all() %}
  </code></pre>
  
  <p>Of course, this doesn't include the ability to see how many pages of results you have, or to generate links to other pages of results.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-18T19:34:40.350Z
Answers.Text: Thank you for reply. Unfortunetly I cant use this method - i still have to use actual paginate tag, because I need "pageInfo" to create pagination links.
Answers.UserDisplayName: Piotr Pogorzelski
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-19T21:15:19.603Z
Answers.Text: I think I might need some more context—you can still paginate the normal set of results, separately, and just run this query off to the side (and use information in your `pageInfo` variable: https://docs.craftcms.com/v3/dev/tags/paginate.html#the-pageinfo-variable)
Answers.UserDisplayName: August Miller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-21T17:49:01.043Z
Answers.Text: I guess i could do that, but some of `pageInfo` variables would be wrong, for example url of next subpage.
Answers.UserDisplayName: Piotr Pogorzelski
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-17T00:30:26.063Z
Answers.LastActivityDate: 2018-11-17T00:30:26.063Z
Answers.UserDisplayName: August Miller
Body: <p><code>{% paginate %}</code> tag takes current subpapage number from url address. Can this behaviour be bypassed and page number be passed directly into <code>{% paginate %}</code> tag?</p>
  
Tags: <pagination>
Title: Manually passing page number to paginate tag
ThreadText: # Manually passing page number to paginate tag
  
  (Asked by: username_0 on 2018-11-16)
  
  `{% paginate %}` tag takes current subpapage number from url address. Can this behaviour be bypassed and page number be passed directly into `{% paginate %}` tag?
  
  **Tags:** pagination
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-10-17. Score: 2 | Accepted answer
  
  Recently i needed such thing again and this time i foud out how to do this:
  
  ```
  {% set query = craft.entries %}
  
  {% set paginator = create('craft\\db\\Paginator', [query, {
      pageSize: 3,
      currentPage: craft.app.request.pageNum,
  }]) %}
  
  {% set pageInfo = create('craft\\web\\twig\\variables\\Paginate').create(paginator) %}
  
  {% set pageResults = paginator.getPageResults() %}
  
  ```
  
  To manually set result page, you need to pass some number to `currentPage` instead of default value taken from URL. Note that initial query cannot have `limit` param, this needs to be passed as `pageSize` param to paginator class.
  
  > **Comments:**
  > **username_1**: OMG that is so incredibly useful - I am building a Nuxt/Craft app and needed some api calls to paginate. It works perfectly. You are a champion! This should be marked as the answer.  
  
  ---
  
  ### Answer by username_2 on 2018-11-17. Score: 2
  
  If you're looking to display a set of Elements that *simulate* a paginated query, you might actually be looking for the `offset` Query parameter.
  
  Here's an example of fetching a “page” of results based on a number of `entriesPerPage` and the number of `pagesToSkip`:
  
  ```
  {% set customPageOfEntries = craft.entries()
      .offset(entriesPerPage * pagesToSkip)
      .limit(entriesPerPage)
      .all() %}
  
  ```
  
  Of course, this doesn't include the ability to see how many pages of results you have, or to generate links to other pages of results.
  
  > **Comments:**
  > **username_0**: Thank you for reply. Unfortunetly I cant use this method - i still have to use actual paginate tag, because I need "pageInfo" to create pagination links.  
  > **username_2**: I think I might need some more context—you can still paginate the normal set of results, separately, and just run this query off to the side (and use information in your `pageInfo` variable: https://docs.craftcms.com/v3/dev/tags/paginate.html#the-pageinfo-variable)  
  > **username_0**: I guess i could do that, but some of `pageInfo` variables would be wrong, for example url of next subpage.  
  
  ---
  
  