<?php
    $categories = get_the_terms($post_id,'create_taxonomy_faq');
    $post_id = get_the_ID();
    $imagefeatured = get_the_post_thumbnail_url($post_id,'featured-single');
    $author = get_field('author_news');
?>
<div id="post-<?php the_ID(); ?>" class="post">
    <section class="l-hero-single-video pt-lg-4">
        <div class="container">
            <a class="c-arrow-prev" href="<?php echo esc_url( home_url( '/help-faqs' ) ); ?>"><i class="icon icon-left-open-big"></i>Back to Help & FAQ</a>
        </div>
        <div class="l-single-video__link row">
            <div class="col-lg-7">
                <div class="c-iframe-video" data-id="<?php echo get_field('id_video'); ?>" style="background: #000 url(<?php echo $imagefeatured; ?>) center/cover no-repeat">
                    <span class="c-box-featured__btn is-single-video is-light">Watch</span>
                </div>
            </div>
            <div class="col-lg-5">
                <article class="c-card-featured is-video">
                    <p class="c-card-featured__meta"><?php echo get_the_date('M'); ?> <?php echo get_the_date('d'); ?>, <?php echo get_the_date('Y'); ?> · <?php echo '<a href="'. esc_url( home_url( '/category-faq/' ) ) . $categories[0]->slug .'">'.$categories[0]->name; ?></a> · <?php echo prefix_estimated_reading_time( get_the_content() ); ?> min read</p>
                    <h3 class="c-card-featured__title feature-title"><?php echo the_title(); ?></h3>
                    <p class="c-card-featured__description"><?php echo get_field('content_video'); ?></p>
                    <?php get_template_part('templates/content', 'share'); ?>
                </article>
            </div>
        </div>
    </section>
    <?php
    $args = array(
        'post_type'      => 'faq',
        'posts_per_page' => 3,
        'post__not_in' => array($post_id),
        //'offset' => 3,
        'post_status' => 'publish',
        'tax_query' => array(
            array(
                'taxonomy' => 'post_format',
                'field' => 'slug',
                'terms' => array( 'post-format-video' ),
                'operator' => 'IN'
            )
        )

    );
    $loop = new WP_Query( $args );

    if ( $loop->have_posts() ):
        ?>
    <section class="l-archive-list l-single-video__video pt-3">
        <div class="container">
            <h3 class="c-subtitle is-dark mb-2">Up Next</h3>
            <div class="row">
                    <?php while ( $loop->have_posts() ) : $loop->the_post();?>
                        <?php
                            $post_id = get_the_ID();
                            $imagefeatured = get_the_post_thumbnail_url($post_id,'related-index');
                            $format = get_post_format( $post_id );
                            if(!$format):
                                $format = "article";
                            endif;
                        ?>
                        <div class="col-md-6 col-lg-4">
                            <div class="c-featured-news">
                                <a href="<?php the_permalink(); ?>">
                                    <img src="<?php echo $imagefeatured; ?>" alt="<?php echo the_title(); ?>">
                                    <div class="c-card-news__type"><i class="icon icon-<?php echo $format; ?>"></i></div>
                                </a>
                            </div>
                            <article class="c-card-category">
                                <p class="c-card-category__meta"><?php echo get_the_date('M'); ?> <?php echo get_the_date('d'); ?>, <?php echo get_the_date('Y'); ?> · <?php echo prefix_estimated_reading_time( get_the_content() ); ?> min read</p>
                                <a href="<?php the_permalink(); ?>">
                                    <h3 class="c-card-category__title"><?php echo the_title(); ?></h3>
                                </a>
                            </article>
                        </div>
                <?php
                    endwhile; wp_reset_query();
                ?>
            </div>
        </div>
    </section>
    <?php endif; ?>
</div>