Having a bit of a brainfart here... If hotspotCategory is my entry's categoryfield and that category group has nested categories, how do I return only the top level categories?
{% set entryCats = entry.hotspotCategory %}
{% if entryCats | length %}
<span class="filter_cat">
{% for cat in entryCats %}
{{ cat.title }} {% if not loop.last %}, {% endif %}
{% endfor %}
</span>
{% endif %}
this works but if I do something like
{% set entryCats = entry.hotspotCategory.level(1).all() %}
I get an
Impossible to invoke a method ("level") on an array.
error.
What am I missing here?
To clarify: my entry has the following categories attached (slow & fast food are subcategories):
- food & dining
--- slow food
--- fast food
Now, on the entry page I only want to display the top level category, not the subcategories.