Created
February 9, 2016 17:21
-
-
Save masiorama/9e9fa6f182114ba8cb0c to your computer and use it in GitHub Desktop.
Craft CMS: Getting entries grouped by category in order of the category type drag & drop order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# 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 #} | |
{% set relatedEntries = craft.entries.relatedTo(category) %} | |
{% for entry in relatedEntries %} | |
{{ entry.title }} | |
{% endfor %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment