I'm trying to upgrade my website to Craft 3 and can't resolve one issue with this piece of code:
{% for category in craft.categories.group('blogCategories').order('title') %}
<li><a href="{{ category.url }}" class="button {{ entry.blogCategory.one().id == category.id ? 'light': 'primary' }}">{{ category.title }}</a></li>
{% endfor %}
I get the following error:
Twig Runtime Error – Twig\Error\RuntimeError Impossible to access an attribute ("id") on a null variable.
I can't find any information in Changes in Craft 3, but I bet there's a new way of getting the category ID of the current post and the entry.blogCategory.one().id
won't work anymore?
Any ideas?