<?php
$post_thumbnail_id = get_post_thumbnail_id(get_the_ID());
$image = wp_get_attachment_image_src($post_thumbnail_id, 'full');
$image_style = "style='background-image:url(" . esc_url($image[0]) . ")'"; ?>

<div class="single-episode-header section"  <?php echo wp_kses_post($image_style); ?>>
    <div class="container">
        <div class="row">
            <div class="col-md-4">
                <?php podcast_guru_post_thumbnail('medium'); ?>
            </div>
            <div class="col-md-8">
            <div class="category-btn-wrap">
                <?php 
                $category = get_the_terms( $post->ID, 'series' );    
                if($category){ 
                foreach ( $category as $cat){ ?>
                
                <a class="category-button" href="<?php echo esc_url( get_term_link( $cat ) ) ?>">
                            <?php echo $cat->name; ?>
                        </a>
                <?php }
                }
                ?>
                </div>
                <header class="entry-header">
                    <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
                    <?php echo do_shortcode('[ss_player]'); ?>
                </header>
            </div>  
        </div>
    </div>
</div>

<div class="single-episode-content section">
    <div class="container">
        <div class="row">
            <div class="entry-content">
                <div class="col-md-8">
                <?php the_content(sprintf(wp_kses(__('Continue reading<span class="screen-reader-text"> "%s"</span>', 'podcast-guru'),array('span' => array('class' => array(),),)),get_the_title())); ?>
                </div>

                <div class="col-md-4">

                <div class="more-series">
                    <h3><?php esc_html_e("More from this Series", "podcast-guru") ?></h3>
                    <ul class="recent-post">
                    <?php
                    if ( $category && ! is_wp_error( $category ) ) :
                        $get_series_categories = array();
                        foreach( $category as $cat ) {
                            $get_series_categories[] = $cat->term_id;
                        }
                    
                        if( !empty( $get_series_categories ) && sizeof($get_series_categories) > 0 ) {
                        $term_args = array(
                            'post_type' => 'podcast',
                            'tax_query' => array(
                                array(
                                'taxonomy' => 'series',
                                'field' => 'term_id',
                                'orderby' => 'post_date',
                                'terms' => $get_series_categories
                                )
                                ),
                                'post__not_in' => array (get_the_ID()), 
                            );
                            $term_posts = new WP_Query( $term_args );

                            if ( $term_posts->have_posts() ) :
                                while( $term_posts->have_posts() ):
                                    $term_posts->the_post();
                                ?>

                                    
                                        <li>
                                            <a href="<?php the_permalink(); ?>" class="recent-post-thumb"><?php the_post_thumbnail('podcast-guru-blog-thumbnail-img'); ?></a>
                                            <div class="item-details">
                                                <h3 class="recent-post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                                <span class="recent-post-date"><time datetime="<?php echo get_the_date('c'); ?>" itemprop="datePublished"><?php echo get_the_date(); ?></time>
    </span>
                                            </div>
                                        </li>
                                    
                                <?php 
                                endwhile;
                            endif;
                        }
                
                    endif;
                    ?>
                    </ul>
                    </div>
                </div>

            <div>
        </div>
    </div>
</div>



 