<?php while ( have_posts() ) : the_post(); ?>
<div class="container">
    <div class="close-btn"></div>
    <div class="voffset90"></div>
    <div class="row">
        <div class="col-md-4">
            <div class="info-album">
                <div class="cover">
                    <?php echo wp_get_attachment_image(get_post_meta(get_the_ID(), '_muziq_jellythemes_album_cover', true ) , 'muziq_jellythemes_album_cover') ?>
                </div>
                <p class="album album-list"><?php echo get_post_meta(get_the_ID(), '_muziq_jellythemes_album_title', true ) ?></p>
                <p class="artist"><?php echo get_post_meta(get_the_ID(), '_muziq_jellythemes_album_artist', true ) ?></p>
                <div class="voffset20"></div>
                <p class="description"><?php echo wp_kses(get_post_meta(get_the_ID(), '_muziq_jellythemes_album_description', true ), array()); ?></p>
                <?php $buy = get_post_meta(get_the_ID(), '_muziq_jellythemes_album_link', true ) ?>
                <?php if (!empty($buy)) :?>
                    <p class="buyalbum">
                        <a href="<?php echo esc_url($buy); ?>" class="btn rounded icon"><i class="fa fa-cart-plus"></i> <?php esc_html_e('buy album', 'muziq-jellythemes'); ?></a>
                    </p>
                <?php endif; ?>
                <ul class="links">
                    <?php $itunes = get_post_meta(get_the_ID(), '_muziq_jellythemes_album_itunes', true ) ?>
                    <?php if (!empty($itunes)): ?>
                        <li><a href="<?php echo esc_html($itunes); ?>">itunes</a></li>
                    <?php endif ?>
                    <?php $spotify = get_post_meta(get_the_ID(), '_muziq_jellythemes_album_spotify', true ) ?>
                    <?php if (!empty($spotify)): ?>
                        <li><a href="<?php echo esc_html($spotify); ?>">spotify</a></li>
                    <?php endif ?>
                    <?php $beatport = get_post_meta(get_the_ID(), '_muziq_jellythemes_album_beatport', true ) ?>
                    <?php if (!empty($beatport)): ?>
                        <li><a href="<?php echo esc_html($beatport); ?>">beatport</a></li>
                    <?php endif ?>
                </ul>
                <div class="voffset80"></div>
            </div>
        </div>
        <div class="col-md-8">
            <?php $back = $post; ?>
            <?php $tracks = new WP_Query(array('post_type'=>'muziq-track',
                                    'posts_per_page' => -1,
                                    'meta_query' => array(
                                        array(
                                            'key' => '_muziq_jellythemes_album',
                                            'value' => get_the_ID()
                                    )))); ?>
            <div class="disc-tracklist">
                <audio preload id="playlist0"></audio>
                <ol class="playlist0">
                    <?php  while ($tracks->have_posts()) : $tracks->the_post(); ?>
                    <li>
                        <a href="#" data-src="<?php echo wp_get_attachment_url(get_post_meta(get_the_ID(), '_muziq_jellythemes_track_file', true )) ?>">
                            <div class="track-info">
                                <p class="track-title"><?php echo get_post_meta(get_the_ID(), '_muziq_jellythemes_track_title', true ) ?></p>
                                <p class="track-album"><?php echo get_post_meta(get_the_ID(), '_muziq_jellythemes_track_artist', true ) ?></p>
                            </div>
                        </a>
                    </li>
                    <?php endwhile; ?>
                </ol>
            </div>
        </div>
    </div>
</div>
<?php endwhile; ?>
