Trouble getting a list of categories that have entries for a specific category group 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 %}
    &lt;h3&gt;{{ handshapeCategory }}&lt;/h3&gt;
{% endfor %}       


Any ideas why the shown categories are not being limited to categories from the 'handshape' category group?
I would reverse your logic:


get all entries in whatever channel
display only categories (from a certain group) that have entries fetched in step 1 attached to them


Something along the lines of:

{% set entries = craft.entries.section('myChannel').limit(null) %}
{% set activeCategories = craft.categories.group('myCatgroup').relatedTo(entries).find() %}


You can then use a simple for loop to display only the active categories