Play audio trough a ACF field using HTML and shortcode

Viewed 11

I am trying to play a audio file when a user clicks on icon. The audio should be determined through a ACF. I am currently trying the following:

<div class="player">
  <img id ="button" onclick="togglePlay()" src ="https://fokus.no/wp-content/uploads/2022/04/Knapp_bakgrunn_Tale_60px.png">
    <audio>
        <source src="<?php the_field('audio_url'); ?>"
    </audio>
</div>

But, it does not work. How can I make this work? I have also tried to use direct shortcode, like this:

<audio>
        <source src="="[acf field='audio_url']">"
    </audio>
</div>

The audio is not playing. I am struggling to manage to get the audio url from a custom field on the page. See this URL for the live icon: https://wp00377.prod.aluweb.no/?page_id=6

0 Answers
Related