1

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.

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() %}
    <a href="?tagId={{ tag.id }}">{{ tag.title }}</a>
{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.