admin管理员组文章数量:1130349
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]
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)
-
Have you tried with
[acf field='sound_file_1']? – Sally CJ Commented Nov 20, 2018 at 7:43 - @SallyCJ yes, it was the first Idea that I have tested – JackB Commented Nov 20, 2018 at 8:02
-
It's probably because WordPress doesn't support nested shortcodes, and the default
[audio]shortcode also doesn't parse shortcode in the audio source (i.e. thesrcparameter). However, you can overcome that, by creating a custom shortcode - e.g.[audio_acf]– Sally CJ Commented Nov 20, 2018 at 8:23
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]
本文标签: pluginsACF for audio url in wordpress audio shortcode
版权声明:本文标题:plugins - ACF for audio url in wordpress audio shortcode 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749164391a2325929.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


[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. thesrcparameter). However, you can overcome that, by creating a custom shortcode - e.g.[audio_acf]– Sally CJ Commented Nov 20, 2018 at 8:23