<p>You can read about how to use <a href="https://docs.craftcms.com/v3/relations.html" rel="nofollow noreferrer">Relations</a> in the docs. All relations such as (Tags) can be fetched via <code>relatedTo</code> parameter in your <code>ElementsQuery</code></p>

<pre class="lang-PHP prettyprint-override"><code>{% set tagId = craft.app.getRequest().getQueryParam('tagId') %}
{% set entries = craft
    .entries
    .section('faq')
    .relatedTo(tagId)
    .all() 
%}
</code></pre>

<p>This assumes you include the parameter <code>tagId</code> when someone clicks on your Tag, and that represents the ID of your Tag</p>

<pre class="lang-TWIG prettyprint-override"><code>{% for tag in craft.tags.group(1).all() %}
    &lt;a href="?tagId={{ tag.id }}"&gt;{{ tag.title }}&lt;/a&gt;
{% endfor %}
</code></pre>

CC BY-SA 4.0
2019-03-13T12:48:31.483Z
2019-03-13T12:48:31.483Z
Robin Schambach
<p>Still very new to Craft but just can't figure this problem out, it's a level above me at the moment.</p>

<p>I have an FAQ page as a 'single' that I would like to display all entries from a channel by default. </p>

<p>But all these entries will have a tag option (either 'red' or 'blue').</p>

<p>How would I sort these entries via a sub nav to display only all, red or blue tagged entries?</p>

<p>Thank you in advance. </p>

<navigation><tags><sorting>
Filter entries by tags
# Filter entries by tags

(Asked by: username_0 on 2019-03-13)

Still very new to Craft but just can't figure this problem out, it's a level above me at the moment.

I have an FAQ page as a 'single' that I would like to display all entries from a channel by default.

But all these entries will have a tag option (either 'red' or 'blue').

How would I sort these entries via a sub nav to display only all, red or blue tagged entries?

Thank you in advance.

**Tags:** navigation, tags, sorting

---

## 1 answers

### Answer by username_1 on 2019-03-13. Score: 1

You can read about how to use Relations in the docs. All relations such as (Tags) can be fetched via relatedTo parameter in your ElementsQuery
{% set tagId = craft.app.getRequest().getQueryParam('tagId') %}
{% set entries = craft
    .entries
    .section('faq')
    .relatedTo(tagId)
    .all() 
%}

This assumes you include the parameter tagId when someone clicks on your Tag, and that represents the ID of your Tag
{% for tag in craft.tags.group(1).all() %}
    {{ tag.title }}
{% endfor %}


---

