0
私はWordpressとACFで木材(小枝)を使用します。木材(小枝)、ループ親
私は、この構造体を作成したいと思います:
<div class="section" id="section1">
<div class="slide slide0">
<div class="image-container" data-type="home" data-currentslide="1" data-maxslides="3" data-title="DEMO" data-project="Sweater Collection (Hamburg, 2017)">
<img src="img/myimage.jpg">
</div>
</div>
<div class="slide slide1">
<div class="image-container" data-type="project" data-currentslide="2" data-maxslides="3" data-title="DEMO" data-project="Sweater Collection (Hamburg, 2017)">
<img src="img/myimage.jpg">
</div>
</div>
<div class="slide slide2">
<div class="image-container" data-type="project" data-currentslide="3" data-maxslides="3" data-title="DEMO" data-project="Sweater Collection (Hamburg, 2017)">
<img src="img/myimage.jpg">
</div>
</div>
</div>
<div class="section" id="section2">
<div class="slide slide0">
<div class="image-container" data-type="project" data-currentslide="1" data-maxslides="3" data-title="DEMO" data-project="Sweater Collection (Hamburg, 2017)">
<img src="img/myimage.jpg">
</div>
</div>
<div class="slide slide1">
<div class="image-container" data-type="project" data-currentslide="2" data-maxslides="3" data-title="DEMO" data-project="Sweater Collection (Hamburg, 2017)">
<img src="img/myimage.jpg">
</div>
</div>
<div class="slide slide2">
<div class="image-container" data-type="project" data-currentslide="3" data-maxslides="3" data-title="DEMO" data-project="Sweater Collection (Hamburg, 2017)">
<img src="img/myimage.jpg">
</div>
</div>
</div>
しかしdata-type
属性のため、私は他に最初のセクションとのプロジェクトのために家を追加する必要があります。親ループのインデックスで試してみますが、うまくいきません。
data-type="{% if loop.parent.loop.index0 %}home{% else %}project{% endif %}"
:
{% for section in sections %}
<div class="section" id="section{{ loop.index }}">
{% for slide in section.get_field('project_imgs') %}
<div class="slide slide{{ loop.index0 }}">
<div class="image-container" data-type="{% if loop.parent.loop.index0 %}home{% else %}project{% endif %}" data-currentslide="{{ loop.index }}" data-maxslides="{{ section.get_field('project_imgs')|length }}" data-title="{{ section.project_title }}" data-project="{{ section.project_legend }}">
<img src="{{site.theme.link}}/assets/img/samples/mac-web.jpg">
</div>
</div>
{% endfor %}
</div>
{% endfor %}
yoあなたは私の答え@Xroadを見ますか? –