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 %}`
  • 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? – Cavell Blood Nov 7 '17 at 18:36
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 %}
  • 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 – Robin Schambach Oct 26 '17 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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