Hello
Maybe can somebody help
I’m build a listig site with artists, and each artist post should have own audio player, in my case Waveplayer (from code canyon)
I’ve made repeater field where the artist can upload mp3-s (output:ID)
Waveplayer generate the shortcode from media library playlist and it looks like this:
[waveplayer ids=”231,230,229,228,227,226,225,224,223,222,221,220″]
On code canyon developer has written some snippet but this is not for repeater field
$audio = get_field( 'audio_file', "user_$user_id" );
if ( $audio && isset( $audio['id'] ) && $audio['id'] ) {
echo do_shortcode( "[waveplayer ids='{$audio['id']}']" );
}
my repeater field is “audio_upload” and mp3 file is “demo_mp3”
How to achieve this?
thanks
I’ve found solution. Big Thanks to Matt Hias from Oxygen FB Group
<?php
if ( have_rows( 'your_repeater_field' ) ) :
$ids = [];
while ( have_rows( 'your_repeater_field' ) ) :
the_row();
$audio = get_sub_field( 'your_mp3_sub_field' );
if ( $audio && isset( $audio['id'] ) && $audio['id'] ) {
$ids[] = $audio['id'];
}
endwhile;
if (count($ids)) {
echo do_shortcode( '[waveplayer ids="' . implode(',', $ids) . '"]' );
}
endif;
?>
You can use this with standard WP Playlist. For shortcode just put playlist instead of waveplayer