Craft CMS Asked by Spheriri on May 21, 2021
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?
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.
Correct answer by Oli on May 21, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP