I have a long list of categories in a specific category group, but only want to show a list of the categories from this group that currently have an entry associated with them.
I've been trying to implement the solution that I found at this thread: How can I output a list of categories that are not empty?
Only categories with related entries are showing. However, it's not being narrowed down to specific to a specific category group. Here's my code below:
{% set handshapeCategories = craft.categories.group('handshape').limit(null) %}
{% set entriesWithHandshapeCategories = craft.entries.relatedTo( handshapeCategories ).limit(null) %}
{% set handshapeCategoriesInUse = craft.categories.relatedTo(entriesWithHandshapeCategories) %}
{% for handshapeCategory in handshapeCategoriesInUse %}
<h3>{{ handshapeCategory }}</h3>
{% endfor %}
Any ideas why the shown categories are not being limited to categories from the 'handshape' category group?