Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-13T12:48:31.483Z
Answers.LastActivityDate: 2019-03-13T12:48:31.483Z
Answers.UserDisplayName: Robin Schambach
Body: <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>
  
Tags: <navigation><tags><sorting>
Title: Filter entries by tags
ThreadText: # 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](https://docs.craftcms.com/v3/relations.html) in the docs. All relations such as (Tags) can be fetched via `relatedTo` parameter in your `ElementsQuery`
  
  ```PHP
  {% 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
  
  ```TWIG
  {% for tag in craft.tags.group(1).all() %}
      <a href="?tagId={{ tag.id }}">{{ tag.title }}</a>
  {% endfor %}
  
  ```
  
  
  ---
  
  