1
{% if block.type == "podcastBlock" %}
    {% for category in block.podcastChannel %}
        {{category.title}} 

        <audio class="mp3" controls>

        {% for entry in block.podcastChannel %}
            <source src="{{ entry.audioFile.one.url }}" type="audio/mp3">
        {% endfor %} 
    {% endfor %}
{% endif %}`
1
  • I'm guessing that you only want to pull in the e2.mp3 file, is that right? Or you want to dynamically choose which one you show? Commented Nov 7, 2017 at 18:36

2 Answers 2

1

Try using the limit:1

{% for entry in block.podcastChannel.limit(1) %}
1

The issue was using two loops. I just needed the initial loop and referencing the loop call with the field-handle together. It now retrieves a single podcast.

{% if block.type == "podcastBlock" %}
    {% set groupTitle  = craft.categories.group('podcasts').one() %}

    {% for podcast in block.podcastChannel %} 
        <p class="subhead-section">{{ groupTitle }}</p>
        <audio class="mp3" controls>
        <source src="{{ podcast.audioFile.one.url }}" type="audio/mp3">
     {% endfor %} 
{% endif %}
1
  • Looping through queries is deprecated, that means sooner or later your {% for podcast in block.podcastChannel %} will trow an exception. Use {% for podcast in block.podcastChannel.all() %} instead. You can see this message in your control panel as well Commented Oct 26, 2017 at 19:45

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.