1

Is is possible to loop through both a category group and tag group in a for loop?

Categories: blue, red, orange Tags: basketball

Loop displays: basketball, blue, orange, red.

2

Something like this may work for you (untested).

{% set categories = craft.categories.group('myCategoryGroup').find %}
{% set tags = craft.tags.group('myTagGroup').find %}
{% set elements = categories|merge(tags) %}
<ul>
    {% for element in elements %}
        <li>{{ element.title }}</li>
    {% endfor %}
</ul>

Sorting them alphabetically is a little more difficult. For that you may want to try twig's sort filter or, failing that, the supersort or craft-twig-better-sort plugins.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.