Skip to content

Instantly share code, notes, and snippets.

View shaneturner's full-sized avatar
🤔

Shane Turner shaneturner

🤔
View GitHub Profile
@shaneturner
shaneturner / craft-cms-entries-by-category-group.twig
Created December 4, 2017 00:26
Craft CMS: Getting entries grouped by category in order of the category type drag & drop order.
{# Get the categories related to my "entrySection" entries in structure order #}
{% set entries = craft.entries.section('entrySection') %}
{% set relatedCats = craft.categories.relatedTo(entries) %}
{# Loop the categories #}
{% for category in relatedCats %}
{{ category.title }}
{# Get and loop through entries related to this cat #}