This WordPress shortcode plays an audio file for you and works great:
[audio src=""]
In a specific post or page ,I want to give it the url of song using Advanced Custom filed (ACF) plugin:
[audio src="[acf field="sound_file_1"]"]
but It does not work and tries to open [acf feild"... as the song url.
(Note that I have defined the url field using acf and tested it alone without audio shortcode and it works)
This WordPress shortcode plays an audio file for you and works great:
[audio src="http://XXX.mp3"]
In a specific post or page ,I want to give it the url of song using Advanced Custom filed (ACF) plugin:
[audio src="[acf field="sound_file_1"]"]
but It does not work and tries to open [acf feild"... as the song url.
(Note that I have defined the url field using acf and tested it alone without audio shortcode and it works)
1 Answer
Reset to default 1I havent tested yet but I think can work, what I would do is create a function to create a new shortcode from those to doing this.
function new_shortcode() {
$urlmusic = get_field('sound_file_1');
echo do_shortcode("[audio src='$urlmusic']");
}
add_shortcode( 'audioACF', 'new_shortcode' );
Use [audioACF]
[acf field='sound_file_1']
? – Sally CJ Commented Nov 20, 2018 at 7:43[audio]
shortcode also doesn't parse shortcode in the audio source (i.e. thesrc
parameter). However, you can overcome that, by creating a custom shortcode - e.g.[audio_acf]
– Sally CJ Commented Nov 20, 2018 at 8:23