Support

Account

Home Forums ACF PRO get_sub_field in javascript not working

Unread

get_sub_field in javascript not working

  • Hi.
    I have a JS player with playlist and I want to input repeater fields in it (create play list)
    This is my repeater code:

    
    <?php if( have_rows('playlist_single_track') ): ?>												
    <?php while( have_rows('playlist_single_track') ): the_row(); 							
    $pltrackname = get_sub_field('playlist_track_name');
    $pldownloadtrack = get_sub_field('playlist_track_download');
    $plplaytrack = get_sub_field('playlist_trak_online_player');
    ?>	
    
    <script>
    const ap = new APlayer({
        container: document.getElementById('playlist'),
        listFolded: false,
        listMaxHeight: 90,
    	preload: 'none',
        audio: [
            {
            name: '<?php echo $pltrackname; ?>',
            artist: 'null',
            url: '<?php echo $plplaytrack; ?>',
            cover: 'images/cover.jpg'
            },
        ]
    });
    
    </script>
    
    <?php endwhile; ?>
    <?php endif; ?>	
    

    this is working fine but it just show 1 track in the list and not loading more tracks.

    I know probably going wrong with the code but can you help me to complete the tracklist in my player?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.