I’m trying to call the url of an mp3 in a field but something keeps going wrong.
<?php
$attr = array(
'src' => 'the_field( track_one)',
'loop' => '',
'autoplay' => '',
'preload' => 'none'
);
echo wp_audio_shortcode( $attr );
?>
When I var_dump the field, it gives me thesongIwant.mp3NULL
Hi @cbmusic
Hmm… Instead of using the_field(), change it to get field. Change your code to the following:
<?php
$attr = array(
'src' => get_field('track_one'),
'loop' => '',
'autoplay' => '',
'preload' => 'none'
);
echo wp_audio_shortcode( $attr );
?>
Check out the doucmentation for get_field() method: http://www.advancedcustomfields.com/resources/get_field