I want to put some audio files in a html table using wordpress default [audio] shortcode and using ACF to take the url of song.
because of using two nested shortcode does not renderrd in wordpress, I have done this using a costume shortcode and a function as it is asked in another question here:
ACF for audio url in wordpress audio shortcode
and now this is my code:
add_shortcode('audio_nested',custume_url_callback);
function custume_url_callback ($atts = ''){
$value = shortcode_atts( array(
'my_feild' => '',
), $atts );
$urlmusic = get_field($value['my_feild']);
echo do_shortcode("[audio src='$urlmusic']");
}
now when I use it in the post contebnts it is OK, but when I use my shortcode in a table, the player does not appear in the table and goes on the top of post contents.
but if I use the default [audio src="XXX.mp3"] in the table it works good and will be placed right in the table cell.
I have tested the tablepress plugin and other plugins for table and also I have wrote a simple html table but no change in result.
here you can see a screenshot of the problem:
.png
I want to put some audio files in a html table using wordpress default [audio] shortcode and using ACF to take the url of song.
because of using two nested shortcode does not renderrd in wordpress, I have done this using a costume shortcode and a function as it is asked in another question here:
ACF for audio url in wordpress audio shortcode
and now this is my code:
add_shortcode('audio_nested',custume_url_callback);
function custume_url_callback ($atts = ''){
$value = shortcode_atts( array(
'my_feild' => '',
), $atts );
$urlmusic = get_field($value['my_feild']);
echo do_shortcode("[audio src='$urlmusic']");
}
now when I use it in the post contebnts it is OK, but when I use my shortcode in a table, the player does not appear in the table and goes on the top of post contents.
but if I use the default [audio src="XXX.mp3"] in the table it works good and will be placed right in the table cell.
I have tested the tablepress plugin and other plugins for table and also I have wrote a simple html table but no change in result.
here you can see a screenshot of the problem:
https://pasteboard.co/HO9A2lw.png
1 Answer
Reset to default 0After spending some days and testing lots of solutions, at last I have solved the problem using wordpress audio php function directly in code instead of using [audio]
shortcode and do_shortcode()
function.
here you can find more detail and how to use it:
https://codex.wordpress/Function_Reference/wp_audio_shortcode