<p>Something like this may work for you (untested).</p>

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

<p>Sorting them alphabetically is a little more difficult. For that you may want to try twig's <a href="http://twig.sensiolabs.org/doc/filters/sort.html" rel="nofollow">sort filter</a> or, failing that, the <a href="http://michaelrog.com/craft/supersort" rel="nofollow">supersort</a> or <a href="https://github.com/victor-in/Craft-TwigBetterSort" rel="nofollow">craft-twig-better-sort</a> plugins.</p>

CC BY-SA 3.0
2015-10-21T18:47:49.223Z
2015-10-21T18:47:49.223Z
Douglas McDonald
<p>Is is possible to loop through both a category group and tag group in a for loop?</p>

<p>Categories: blue, red, orange
Tags: basketball</p>

<p>Loop displays: basketball, blue, orange, red.</p>

<loop>
Loop through both category group and tag group in single loop
# Loop through both category group and tag group in single loop

(Asked by: username_0 on 2015-10-21)

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.

**Tags:** loop

---

## 1 answers

### Answer by username_1 on 2015-10-21. Score: 2 | Accepted answer

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) %}

    {% for element in elements %}
        {{ element.title }}
    {% endfor %}


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.


---

