Skip to content

Instantly share code, notes, and snippets.

@dustinwalker
Created February 18, 2014 15:56
Show Gist options
  • Save dustinwalker/9073679 to your computer and use it in GitHub Desktop.
Save dustinwalker/9073679 to your computer and use it in GitHub Desktop.
Find tags in given tag group, list tags and entries under each tag
{#
# FIELD_NAME is name of field
# sampleCategories, sampleCategory, category, entry, entries can be anything
#}
{% set sampleCategories = craft.tags.set('FIELD_NAME') %}
<ul>
{% for sampleCategory in sampleCategories %}
{% set category = craft.tags.search('name:'~sampleCategory.name).first() %}
{% if category %}
<li>
<h2>{{ category }}</h2>
{% set entries = craft.entries.parentOf(category).find() %}
<ul>
{% for entry in entries %}
<li>{{ entry.title }}</li>
{% endfor %}
</ul>
</li>
{% else %}
{% exit 404 %}
{% endif %}
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment