E
E
Evgeny Zhurov2020-06-21 18:15:45
Twig
Evgeny Zhurov, 2020-06-21 18:15:45

How to display posts related to a category if the category is set in the field type matrix (Craft CMS)?

There are posts with data about books. There is an entity "category" with authors. But the authors should not be specified directly in the post, but using the matrix field type, one of the field types of which is the "author" category.

Screenshots

Настройки самого поля:
5eef78aadc9e4246487507.png
Размещение в посте:
5eef78f93bebc153753611.png

If the author were specified directly, without matrix, then a simple construction in twig would work to display all the books of the author on the category page:
{% for entry in craft.entries.section('bookPost').relatedTo(category) %}
  {{ entry.title }}
{% endfor %}


But in the case of matrix, this does not work. On the one hand, it is clear why, but it is not clear how to make it work?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question