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)?

1 Answer 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...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.