<?php
/**
 * Template Name: TV
 *
 * Template for displaying a page without sidebar even if a sidebar widget is published.
 *
 * @package BBase_Code
 */


defined( 'ABSPATH' ) || exit;

get_header(); the_post(); ?>

<?php
if ( function_exists('yoast_breadcrumb') ) {
    yoast_breadcrumb( '<div class="container" id="breadcrumbs">','</div>' );
}
?>

<div class="container body-content">
    <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</div>

<?php 
$args = array(
	'post_type'              => array( 'onon_tv' ),
	'posts_per_page'         => '-1',
);

$query = new WP_Query( $args );
?>

<?php if ( $query->have_posts() ) : ?>
<div class="wrap-tivi">
    <div class="container">
        <div class="list-tivi">      
            
            <?php while ( $query->have_posts() ) : $query->the_post(); ?>
            <div class="tivi-item">
                <div class="wrap-img">
                    <a class="video-wrap" video-url="<?php the_field( 'video_url' ) ?>" href="#" data-bs-toggle="modal" data-bs-target="#staticBackdrop-<?php the_ID(); ?>">
                        <img src="<?php echo custom_image_size( get_the_ID(), 1024, 575, true ) ?>" alt="<?php esc_html_e( get_sub_field( 'title' ), 'text' ) ?>" />
                    </a>
                </div>
                <div class="wrap-info">
                    <h3 class="title"><?php the_title() ?></h3>
                    <div class="des"><?php the_content() ?></div>
                </div>

                <!-- Modal -->
                <div class="modal modal-video fade" id="staticBackdrop-<?php the_ID(); ?>" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
                    <div class="modal-dialog product-popup video-popup modal-dialog-centered">
                        <div class="modal-content">
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                            
                            <div class="form-order product-box video-youtube-wrap">
                                <?php echo wp_oembed_get( get_field( 'video_url' ), array( 'width' => 1200 ) ); ?>
                            </div>
                        </div>
                    </div>
                </div>                
            </div>
            <?php endwhile ?>

        </div>
    </div>
</div>
<?php endif; 
wp_reset_postdata();?>

<?php get_footer() ?>