<p>I've not actually done this, but I'm guessing:</p>

<p><code>{% set category = entry.categoriesFieldHandle.last() %}</code></p>

<p>(...then <code>.level</code> on that to get the level if that's what you want).  <code>.last()</code> is the opposite of <code>first()</code>.  </p>

<p>(Make sure you check <code>category|length</code> as it might be that no categories are assigned...)</p>

CC BY-SA 3.0
2017-02-07T23:29:01.383Z
2017-02-07T23:29:01.383Z
Jeremy Daalder
<p>Some categories have 2 levels, some only have 1 level.</p>

<p>How can I print the "last" level of an entry if for some it is level(2) and others it is level(1)?</p>

<templating>
How do I print the last level of a category?
# How do I print the last level of a category?

(Asked by: username_0 on 2017-02-07)

Some categories have 2 levels, some only have 1 level.

How can I print the "last" level of an entry if for some it is level(2) and others it is level(1)?

**Tags:** templating

---

## 1 answers

### Answer by username_1 on 2017-02-07. Score: 1

I've not actually done this, but I'm guessing:

`{% set category = entry.categoriesFieldHandle.last() %}`

(...then `.level` on that to get the level if that's what you want). `.last()` is the opposite of `first()`.

(Make sure you check `category|length` as it might be that no categories are assigned...)


---

