How to filter entries based on Tags 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?



The results will show entries with the Blue tag, entries with the Yellow tag and entries with the Triangle tag. 

Thanks so much!
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 ?? [] %}

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