Taxonomy field render options
By default, Advanced Views displays the Taxonomy field as term link(s). You can customize the Layout template to change how it's rendered:
1. Hierarchical terms
By default, all the items displayed in the same order, in which were selected in the field. If your taxonomy supports hierarchy, and you want to reflect it on the front, you can group the items by the parent_id field.
See the Twig template example below.
<acf-view-65ae6721b4917 class="{{ _layout.classes }}avf-layout avf-layout--id--{{ _layout.id }} avf-layout--object-id--{{ _layout.object_id }}">
{% if taxonomy.value %}
<div class="avf-layout__taxonomy">
{% for term_item in taxonomy.value %}
{% if 0 == term_item.parent_id %}
[acf_views view-id="{{ taxonomy.view_id }}" object-id="term" term-id="{{ term_item.value }}"]
{% set children = [] %}
{% for inner_term_item in taxonomy.value %}
{% if term_item.value == inner_term_item.parent_id %}
{% set children = children|merge([inner_term_item]) %}
{% endif %}
{% endfor %}
{% if children %}
<div class="children">
{% for child_term_item in children %}
[acf_views view-id="{{ taxonomy.view_id }}" object-id="term" term-id="{{ child_term_item.value }}"]
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endfor %}
</div>
{% endif %}
</acf-view-65ae6721b4917>2. Terms Slider (Pro)
Advanced Views comes with a set of pre-configured JS libraries, so you can easily turn the term items into a slider. Before activating the slider feature, read the 'displaying term details' section to learn how to setup the details look for each item.
After adding the Taxonomy field to the target Layout, change the 'Enable Slider' option to 'Splide v4' and Save. It'll automatically change the field markup to incorporate the necessary classes, and add the default JS instance:
You can customize it according to your needs, using any available Splide options.
Last updated