Answers.Body: <p>I think what you are trying to achieve here has little to do with the actual templating itself. You can add your tags as data-attributes like so</p>
  
  <pre><code>{% set entries = craft.entries.section('yoursection') %}
  &lt;ul&gt;
  {% for entry in entries %)
     &lt;li data-tag={% for tags in entry.tagsFieldHandle %){{tag.title}}{% endfor %}&gt;{{entry.title}}&lt;/li&gt;
  {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>You set the tags for each entry, so you'll be able to hide/show entries with the right tags.</p>
  
  <p>Then you can simply use javascript on the checkboxes to match for one of these tags in the data attributes.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-17T22:06:29.827Z
Answers.LastActivityDate: 2017-01-17T22:06:29.827Z
Answers.UserDisplayName: Jan_dh
Answers.Body: <p>You can combine multiple relationship criteria by passing an array to the <code>relatedTo</code> parameter with the keyword <code>'and'</code> or <code>'or'</code> as the first array element. You want your entries to be related to any of the tags, so this should work for you:</p>
  
  <pre><code>{% set query = craft.request.getQuery() %}
  
  {# Make sure selectedTagIds is an array #}
  {% set selectedTagIds = query.tags ?? [] %}
  
  &lt;form action=""&gt;
      {% for tag in craft.tags.group('colorTag') %}
          {% set checkedAttr = tag.id in selectedTagIds ? 'checked' : '' %}
          &lt;input type="checkbox" name="tags[]" value="{{ tag.id }}" {{ checkedAttr }}&gt;{{ tag.name }}&lt;/input&gt;
      {% endfor %}
  
      {% for tag in craft.tags.group('shapeTag') %}
          {% set checkedAttr = tag.id in selectedTagIds ? 'checked' : '' %}
          &lt;input type="checkbox" name="tags[]" value="{{ tag.id }}" {{ checkedAttr }}&gt;{{ tag.name }}&lt;/input&gt;
      {% endfor %}
  
      &lt;button type="submit"&gt;Search&lt;/button&gt;
  &lt;/form&gt;
  
  {# Prepare our relatedTo parameter #}
  {% set relatedToParam = ['or'] %}
  
  {% for id in selectedTagIds %}
      {% set relatedToParam = relatedToParam|merge([{
          targetElement: id
      }]) %}
  {% endfor %}
  
  {# Make sure to not pass the param with just the 'or' in the array #}
  {% set relatedToParam = relatedToParam|length &gt; 1 ? relatedToParam : null %}
  
  {% set entries = craft.entries({
      section: 'foo',
      relatedTo: relatedToParam,
  }) %}
  
  {# Query for the entries and return them #}
  {% for entry in entries %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-17T19:41:05.323Z
Answers.Text: Can you explain where to include the tags name and how to construct the form?. Thanks!
Answers.UserDisplayName: Ricardo Henriquez
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-17T22:48:05.053Z
Answers.Text: I’d rather go with the tags’s IDs instead of the names, saves us some work to query for the tags by their names. Updated the answer and added the form to make it complete.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-13T09:45:33.873Z
Answers.LastActivityDate: 2017-01-17T22:44:31.963Z
Answers.LastEditDate: 2017-01-17T22:44:31.963Z
Answers.UserDisplayName: carlcs
Body: <p>I am working on a site that requires a filter option based on tags.
  Each entry will have two sets of tags (e.g., colors and shapes)</p>
  
  <pre><code>{% for tag in craft.tags.group('colorTag') %}
  {% for tag in craft.tags.group('shapeTag') %}
  </code></pre>
  
  <p>How can I create a filter that allows you to check boxes for those tags and display the results that match ANY of the selected tags?</p>
  
  <p><a href="https://i.sstatic.net/sbaag.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/sbaag.png" alt="enter image description here"></a></p>
  
  <p>The results will show entries with the Blue tag, entries with the Yellow tag and entries with the Triangle tag. </p>
  
  <p>Thanks so much!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-10T00:41:33.603Z
Comments.Text: You're specifically looking for entries where _any_ of those tags match, correct?  i.e. "blue or yellow or triangle".  Or is it "(blue or yellow) AND triangle"?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-10T14:43:01.900Z
Comments.Text: Yes, where ANY of the tags match, so any entry with a blue, or a yellow or a triangle tag.
Comments.UserDisplayName: Ricardo Henriquez
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-17T20:17:47.570Z
Comments.Text: The filtering is from within the CMS right? Not user-based from the page
Comments.UserDisplayName: Jan_dh
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-17T20:24:36.317Z
Comments.Text: @Jan_dh User based from the front-end.
Comments.UserDisplayName: Ricardo Henriquez
Tags: <entry><search><filter><tag>
Title: How to filter entries based on Tags
ThreadText: # How to filter entries based on Tags
  
  (Asked by: username_0 on 2017-01-09)
  
  I am working on a site that requires a filter option based on tags.
  Each entry will have two sets of tags (e.g., colors and shapes)
  
  ```
  {% for tag in craft.tags.group('colorTag') %}
  {% for tag in craft.tags.group('shapeTag') %}
  
  ```
  
  How can I create a filter that allows you to check boxes for those tags and display the results that match ANY of the selected tags?
  
  [![enter image description here](https://i.sstatic.net/sbaag.png)](https://i.sstatic.net/sbaag.png)
  
  The results will show entries with the Blue tag, entries with the Yellow tag and entries with the Triangle tag.
  
  Thanks so much!
  
  **Tags:** entry, search, filter, tag
  
  > **Comments:**
  > **username_1**: You're specifically looking for entries where _any_ of those tags match, correct?  i.e. "blue or yellow or triangle".  Or is it "(blue or yellow) AND triangle"?  
  > **username_0**: Yes, where ANY of the tags match, so any entry with a blue, or a yellow or a triangle tag.  
  > **username_2**: The filtering is from within the CMS right? Not user-based from the page  
  > **username_0**: @username_2 User based from the front-end.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-01-13. Score: 5 | Accepted answer
  
  You can combine multiple relationship criteria by passing an array to the `relatedTo` parameter with the keyword `'and'` or `'or'` as the first array element. You want your entries to be related to any of the tags, so this should work for you:
  
  ```
  {% set query = craft.request.getQuery() %}
  
  {# Make sure selectedTagIds is an array #}
  {% set selectedTagIds = query.tags ?? [] %}
  
  <form action="">
      {% for tag in craft.tags.group('colorTag') %}
          {% set checkedAttr = tag.id in selectedTagIds ? 'checked' : '' %}
          <input type="checkbox" name="tags[]" value="{{ tag.id }}" {{ checkedAttr }}>{{ tag.name }}</input>
      {% endfor %}
  
      {% for tag in craft.tags.group('shapeTag') %}
          {% set checkedAttr = tag.id in selectedTagIds ? 'checked' : '' %}
          <input type="checkbox" name="tags[]" value="{{ tag.id }}" {{ checkedAttr }}>{{ tag.name }}</input>
      {% endfor %}
  
      <button type="submit">Search</button>
  </form>
  
  {# Prepare our relatedTo parameter #}
  {% set relatedToParam = ['or'] %}
  
  {% for id in selectedTagIds %}
      {% set relatedToParam = relatedToParam|merge([{
          targetElement: id
      }]) %}
  {% endfor %}
  
  {# Make sure to not pass the param with just the 'or' in the array #}
  {% set relatedToParam = relatedToParam|length > 1 ? relatedToParam : null %}
  
  {% set entries = craft.entries({
      section: 'foo',
      relatedTo: relatedToParam,
  }) %}
  
  {# Query for the entries and return them #}
  {% for entry in entries %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Can you explain where to include the tags name and how to construct the form?. Thanks!  
  > **username_3**: I’d rather go with the tags’s IDs instead of the names, saves us some work to query for the tags by their names. Updated the answer and added the form to make it complete.  
  
  ---
  
  ### Answer by username_2 on 2017-01-17. Score: 2
  
  I think what you are trying to achieve here has little to do with the actual templating itself. You can add your tags as data-attributes like so
  
  ```
  {% set entries = craft.entries.section('yoursection') %}
  <ul>
  {% for entry in entries %)
     <li data-tag={% for tags in entry.tagsFieldHandle %){{tag.title}}{% endfor %}>{{entry.title}}</li>
  {% endfor %}
  </ul>
  
  ```
  
  You set the tags for each entry, so you'll be able to hide/show entries with the right tags.
  
  Then you can simply use javascript on the checkboxes to match for one of these tags in the data attributes.
  
  
  ---
  
  