plugin development - using wordpress acf shortcods in tables goes outside the table

admin2025-06-06  10

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

Share Improve this question asked Nov 21, 2018 at 6:42 JackBJackB 51 silver badge3 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

After 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

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749157149a316850.html

最新回复(0)