I've got a Section that uses a Matrix field, that has a block, that has a categories field in it.

I want to find all entries using this Matrix field, who has a categories field and has a certain category selected.

Tried the sloution given in the following URL, but no luck: [Find entries that have a category selected from a category field within a matrix block

I have a category group faqCategory. Inside that 3 categories Transport Category (transport-category), Room Category (room-category) and Services Category (services-category).

I have Matrix custom field defined called faqList, which has Block Type FAQ, inside FAQ block 3 fields faqCat(Type of above faqCategory), Question(Type of Text) and Answer(Type of Text).

Another text field called pageTitle.

There is a Single Type section called faqsPage, which has entry Types pageTitle and faqList.

Based on the above provided solution for the original question I have programmed it as follows:

{% nav category in craft.categories.group('faqCategory') %}

    <b>{{ category.title }}</b></br>

    {% set entries = craft.entries.section('faqsPage').relatedTo({
        targetElement: category,
        field: 'faqList.faqCat'
    }) %}

    {% for entry in entries %}

        {{ entry.title }}</br>

    {% endfor %}

{% endnav %}    

Following is the output:

Transport Category

FAQs Page

Room Category

FAQs Page

Services Category

FAQs Page

Instead of proper entries it returns page itself. Please help.

Your Answer

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

Browse other questions tagged or ask your own question.