1

I'm abit lost as to how to structure my FAQ page.

I have a single FAQ page that pulls in every FAQ post, these posts come from the FAQ Entries channel.

But

On the single FAQ page, how do I add a navigation that only shows certain FAQ Entries using categories?

1 Answer 1

2

If I understand properly, you want to show related FAQ based on categories.

On your entry template, you could do something like this:

{# Fetch the categories of the current entry #}
{% set entryCategories = entry.yourCategoriesFieldHandle.all() %}

{# Find related entries #}
{% set relatedFaqs = craft.entries()
    .section('faqs')
    .relatedTo(entryCategories)
    .all() %}

{# Display related FAQs #}
<ul>
{% for entry in relatedFaqs %}
    <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>   
{% endfor %}
</ul>

Change yourCategoriesFieldHandle to what your field handle is and .section('faqs') to the correct section handle for your FAQ's section.

1
  • Thank you very much!
    – Spheriri
    Mar 17, 2021 at 20:44

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.