I'm grabbing a list of categories and displaying their entry count. How can I only display categories which have entires? So I'm not getting any with 0 in them, which is occurring as I have a few entries not yet published with new categories.

{% nav category in craft.categories.group('insights') %}
{# Get the count of entries related to `category` #}
{% set entryCount = craft.entries.relatedTo(category).total() %}
        <a href="{{ category.url }}">{{ category.title }} ({{ entryCount }})</a>
{% endnav %}

1 Answer 1


A simple but effective solution would be to just wrap the output in a conditional.

{% if entryCount %}
{% endif %}
  • Oh that is super simple. Excellent, thanks!
    – sarah3585
    Commented Apr 4, 2016 at 12:59

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.