最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin8PV0评论

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

Post a comment

comment list (0)

  1. No comments so far