0

Here's my code:

{% for category in craft.categories.group('artistLocation') %}

    {% set entryCount = craft.entries.relatedTo(category).total() %}

    {% if entryCount %}
        <li>
            <a href="{{ category.url }}">{{ category.title }} ({{ entryCount }})</a>
        </li>
    {% endif %}

{% endfor %}

For some reason, this is only returning the first six categories with entries associated.

https://www.dropbox.com/s/a2ut7j48acnq1g0/Screenshot%202016-05-06%2010.49.34.png?dl=0

Nothing in the error logs that are shedding any light on it for me.

Any ideas would be awesome!

  • Hard to tell without looking at your database, but are you sure you actually have more than 6 artistLocation categories assigned to various entries? – Brad Bell May 6 '16 at 17:03
2

How many categories do you have in that locations group? A criteria model returns the first 100 elements only by default, so any category falling behind that wouldn't be listed, no matter if there's related entries or not.

Add limit(null) to your craft.categories criteria model to make it return all categories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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