Answers.Body: <p>If you are not going to update your current project to Craft 3 (which will break nearly all your templates and all plugins anyway) you don't need to bother about that message. This is only for Craft 3 and not for Craft 2.</p>
  
  <p>Otherwise looking in the <a href="https://docs.craftcms.com/v3/changes-in-craft-3.html#element-queries" rel="nofollow noreferrer">docs</a> might be a good idea. You can do</p>
  
  <pre><code>{% set query = craft.entries().section('news') %}
  {% set total = query.count() %}
  {% set last = query.nth(total - 1) %}
  </code></pre>
  
  <p>or </p>
  
  <pre><code>{% set oldest = craft.entries()
      .section('news')
      .inReverse()
      .one() 
  %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-30T01:29:46.070Z
Answers.Text: So I am working in Craft 3 already and that link to the docs is very useful. I implemented `nth(query.count() - 1)` and it worked great. Thank you.
Answers.UserDisplayName: TRIM
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-28T06:38:48.363Z
Answers.Text: That docs link is now dead. This [one](https://github.com/craftcms/docs/blob/341b0d451507944dea8ba4bbefadce5a7298315d/en/changes-in-craft-3.md#last)  might be comparable. It also suggests: In most cases you can replace calls to `.last()` with `.inReverse().one()`
Answers.UserDisplayName: kr37
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-08T13:33:30.673Z
Answers.Text: @kr37 your link is now dead as well. Any updated?
Answers.UserDisplayName: Christopher Healey
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-09T14:22:24.727Z
Answers.Text: At this point, I'd say go to [https://docs.craftcms.com/v3/](https://docs.craftcms.com/v3/) and search for inReverse
Answers.UserDisplayName: kr37
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-11-29T15:36:02.950Z
Answers.LastActivityDate: 2019-02-22T19:00:08.913Z
Answers.LastEditDate: 2019-02-22T19:00:08.913Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I have a matrix block that calls a category channel. The categories are nested three levels "deep" at times. I want to select first, second or third level links as needed.</p>
  
  <p>When I use .last(), I can get the full url path to return. When I use .nth(n), I have to specify a value, which automatically limits the link path to that level of "deepness". </p>
  
  <p>What can I do to <strong>get the .last() functionality, without using .last()?</strong></p>
  
  <p>Note: <em>.last() will be deprecated going forward in Craft 3 and beyond</em>.</p>
  
  <hr>
  
Tags: <categories><craft3>
Title: Need .last() functionality for categories – .last() will be deprecated going forward
ThreadText: # Need .last() functionality for categories – .last() will be deprecated going forward
  
  (Asked by: username_0 on 2017-11-29)
  
  I have a matrix block that calls a category channel. The categories are nested three levels "deep" at times. I want to select first, second or third level links as needed.
  
  When I use .last(), I can get the full url path to return. When I use .nth(n), I have to specify a value, which automatically limits the link path to that level of "deepness".
  
  What can I do to **get the .last() functionality, without using .last()?**
  
  Note: *.last() will be deprecated going forward in Craft 3 and beyond*.
  
  ---
  
  **Tags:** categories, craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-29. Score: 7 | Accepted answer
  
  If you are not going to update your current project to Craft 3 (which will break nearly all your templates and all plugins anyway) you don't need to bother about that message. This is only for Craft 3 and not for Craft 2.
  
  Otherwise looking in the [docs](https://docs.craftcms.com/v3/changes-in-craft-3.html#element-queries) might be a good idea. You can do
  
  ```
  {% set query = craft.entries().section('news') %}
  {% set total = query.count() %}
  {% set last = query.nth(total - 1) %}
  
  ```
  
  or
  
  ```
  {% set oldest = craft.entries()
      .section('news')
      .inReverse()
      .one() 
  %}
  
  ```
  
  > **Comments:**
  > **username_0**: So I am working in Craft 3 already and that link to the docs is very useful. I implemented `nth(query.count() - 1)` and it worked great. Thank you.  
  > **username_2**: That docs link is now dead. This [one](https://github.com/craftcms/docs/blob/341b0d451507944dea8ba4bbefadce5a7298315d/en/changes-in-craft-3.md#last)  might be comparable. It also suggests: In most cases you can replace calls to `.last()` with `.inReverse().one()`  
  > **username_3**: @username_2 your link is now dead as well. Any updated?  
  > **username_2**: At this point, I'd say go to [https://docs.craftcms.com/v3/](https://docs.craftcms.com/v3/) and search for inReverse  
  
  ---
  
  