Answers.Body: <p>You could add a new param to the request called <code>skip</code> and use that on your homepage, and default it to zero to allow you to reuse the endpoint elsewhere.</p>
  <pre><code>$skipEntries = Craft::$app-&gt;request-&gt;getParam('skip') ?? 0;
  $criteria = [
      'section' =&gt; $settings['section'], 
      'limit' =&gt;  $settings['limit'],
      'offset' =&gt;  ($settings['limit'] * Craft::$app-&gt;request-&gt;getParam('offset')) + $skipEntries,
      'order' =&gt; $settings['orderBy'],
  ];
  </code></pre>
  <p>You'll need to add the <code>skip</code> parameter to the <code>data</code> object in the jQuery <code>$.ajax</code> request options object for your homepage implementation:</p>
  <pre><code>$.ajax({
      // some params here
      data: {
          skip: 6,
          offset: lazy_offset,
          settings: lazy_settings,
      },
      // some more params here
  }
  </code></pre>
  <p>Other pages would omit the <code>skip</code> parameter. That's one way of solving the problem.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-09T18:33:20.037Z
Answers.Text: That worked great! Any ideas on how to only grab entries of whatever category the page is? eg. load more entries of X category when you're on Page X?
Answers.UserDisplayName: Justin Kendall
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-09T18:43:16.820Z
Answers.Text: Currently when I add `relatedTo(category)` to the loop, it works sorta, but it will also load all the rest of the entries after it's gone through the entries of that category.
Answers.UserDisplayName: Justin Kendall
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-09T14:13:22.623Z
Answers.LastActivityDate: 2020-07-09T14:13:22.623Z
Answers.UserDisplayName: Martin Spain
Body: <p>Following up on a previous question of mine:
  <a href="https://craftcms.stackexchange.com/questions/35747/how-to-skip-the-first-few-entries-in-a-load-more-scenario-with-element-api">How to skip the first few entries in a &quot;load more&quot; scenario with Element API?</a></p>
  <p>I have a website that utilizes the &quot;load More&quot; (button) method shown here:
  <a href="http://craftsnippets.com/articles/infinite-scrolling-and-lazy-loading-with-craft-cms" rel="nofollow noreferrer">http://craftsnippets.com/articles/infinite-scrolling-and-lazy-loading-with-craft-cms</a></p>
  <p>On my site, I have a homepage that displays the first 6 post in a featured way, then below I have a &quot;more posts&quot; area. In my previous question, I was shown how to deal with skipping the fist 6 posts in the loop of the &quot;load more&quot; area.</p>
  <p>However, I want to use the &quot;load more&quot; button elsewhere on the site. Such as:</p>
  <ol>
  <li>Category Page – Same as the Homepage, but only showing more entries in whatever category the page is.</li>
  <li>Individual Entry Page – In this instance I need the &quot;Load More&quot; area to not skip the first 6 entries.</li>
  </ol>
  <p>I can't seem to figure out how use this method in different ways across the site, because the settings for one instance bleeds into the other instances. So, how can I accomplish this? (sorry if this is basic stuff. dealing with API is still new to me)</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-09T06:54:55.490Z
Comments.Text: I still think you should just use the native pagination feature for this as I answered earlier (https://craftcms.stackexchange.com/a/35744/271) - it's much simpler than using the Element API and you can have different settings for each implementation.
Comments.UserDisplayName: James Smith
Tags: <craft3><php><plugin-elementapi><javascript>
Title: How to use multiple different instances Element API "Load More" button?
ThreadText: # How to use multiple different instances Element API "Load More" button?
  
  (Asked by: username_0 on 2020-07-08)
  
  Following up on a previous question of mine:
  [How to skip the first few entries in a "load more" scenario with Element API?](https://craftcms.stackexchange.com/questions/35747/how-to-skip-the-first-few-entries-in-a-load-more-scenario-with-element-api)
  
  I have a website that utilizes the "load More" (button) method shown here:
  <http://craftsnippets.com/articles/infinite-scrolling-and-lazy-loading-with-craft-cms>
  
  On my site, I have a homepage that displays the first 6 post in a featured way, then below I have a "more posts" area. In my previous question, I was shown how to deal with skipping the fist 6 posts in the loop of the "load more" area.
  
  However, I want to use the "load more" button elsewhere on the site. Such as:
  
  1. Category Page – Same as the Homepage, but only showing more entries in whatever category the page is.
  2. Individual Entry Page – In this instance I need the "Load More" area to not skip the first 6 entries.
  
  I can't seem to figure out how use this method in different ways across the site, because the settings for one instance bleeds into the other instances. So, how can I accomplish this? (sorry if this is basic stuff. dealing with API is still new to me)
  
  **Tags:** craft3, php, plugin-elementapi, javascript
  
  > **Comments:**
  > **username_1**: I still think you should just use the native pagination feature for this as I answered earlier (https://craftcms.stackexchange.com/a/35744/271) - it's much simpler than using the Element API and you can have different settings for each implementation.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-07-09. Score: 2 | Accepted answer
  
  You could add a new param to the request called `skip` and use that on your homepage, and default it to zero to allow you to reuse the endpoint elsewhere.
  
  ```
  $skipEntries = Craft::$app->request->getParam('skip') ?? 0;
  $criteria = [
      'section' => $settings['section'], 
      'limit' =>  $settings['limit'],
      'offset' =>  ($settings['limit'] * Craft::$app->request->getParam('offset')) + $skipEntries,
      'order' => $settings['orderBy'],
  ];
  
  ```
  
  You'll need to add the `skip` parameter to the `data` object in the jQuery `$.ajax` request options object for your homepage implementation:
  
  ```
  $.ajax({
      // some params here
      data: {
          skip: 6,
          offset: lazy_offset,
          settings: lazy_settings,
      },
      // some more params here
  }
  
  ```
  
  Other pages would omit the `skip` parameter. That's one way of solving the problem.
  
  > **Comments:**
  > **username_0**: That worked great! Any ideas on how to only grab entries of whatever category the page is? eg. load more entries of X category when you're on Page X?  
  > **username_0**: Currently when I add `relatedTo(category)` to the loop, it works sorta, but it will also load all the rest of the entries after it's gone through the entries of that category.  
  
  ---
  
  