I've got an event entry with each day of the event in a matrix field block. The block has a date field eventDate and I've got it set up so each block has a unique page that display with the date in segment_3 of the url in this format 2023-07-01

On that page I want to display the matrix again, but only that days block. I cannot figure out how to call a block where the dateEvent field matches the url segment.

Below works with a conditional but it's also pulling in all matrix blocks, not the single block that we need.

ideally there'd be a way to query a field in the block like this where 2023-07-01 is the date field value I want to filter by (coming from url segment 3).

{% for block in entry.eventSchedule.eventDate('2023-07-01')collect() %}
  more code here
{% endfor %}

Current full code

{% set entrySlug = craft.app.request.getSegment('2') %}
{% set eventDaySlug = craft.app.request.getSegment('3') %}
{% set entry = craft.entries.slug(entrySlug).one() %}

{% for block in entry.eventSchedule.collect() %}
    using a conditional to match the date works
    however still loading in all the other matrix blocks
    ideally we'd be able to filter in the for loop by checking the field value there.
  {% if block.eventDate|date('Y-m-d') == eventDaySlug %}
    <h3 class="font-semibold text-green-700">{{ block.eventTitle }}</h3>
    <p class="mb-8">{{ block.eventDate|date('Y-m-d') }}</p>
  {% endif %}
{% endfor %}

1 Answer 1


You should be able to do something like this:

{% for block in entry.eventSchedule
  • Excellent. Thank you.
    – CreateSean
    May 29, 2023 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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