<?php get_header();

/* Template Name: Template TvIapi */

$pageTitle = "TV IAP";

include('headerInterna.php');



$datas = [];

query_posts( array( 'post_type' => 'tv_iap', 'showposts' => 99999999 ));

if(have_posts()):

    while (have_posts () ): the_post () ;

        

        $periodo = get_the_date('F, Y');

        $periodo = str_replace(",", " /", $periodo);

        $periodo = ucfirst($periodo);

        

        array_push($datas, $periodo);

    endwhile;

endif;

wp_reset_query();



$datas = array_unique($datas);



?>



<section id='Events'>

    <main>

        <div class='EventFilter'>

        <form action="/search-tv/" id='FiltroSearch'>

                <i class="material-icons" id='buttonFilter'>search</i>

                <input type="text" placeholder="Pesquise" name='filter' id='filterinput'>



            <span>

                <i class="material-icons">calendar_today</i>

                <select name="periodo" id="periodo">

                    <option value="Nenhum" style='color: #06234a;'>Filtre por data</option>

                    <?php

                    foreach($datas as $data)

                    { 

                        ?>

                    <option value="<?=$data?>" style='color: #06234a;'>

                    <?=$data?>

                    </option>

                   <?php }

                    ?>



                </select>

            </span>

            </form>

        </div>

        <div class='Content ContentEvents' id='TvIap'><?php

        query_posts( array( 'post_type' => 'tv_iap', 'showposts' => 99999999 ));

if(have_posts()):

    while (have_posts () ): the_post () ;

    $link_do_video        = get_field('link_do_video');

    $titulo_do_video    = get_field('titulo_do_video');

    $descricao_do_video       = get_field('descricao_do_video');

    $link_do_video = substr($link_do_video, 32);



    ?>



            <div class='EventsBox'>

                <div class='EventosImg'>

                    <iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo $link_do_video;?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>                </div>

                <div class='EventosDesc'>

                    <h3><?php echo $titulo_do_video; ?></h3>

                    <p><?php echo $descricao_do_video;?></p>

                </div>

                    </div>

<?php

endwhile;



endif;

wp_reset_query();

?>



        </div>

    </main>

    

</section>



<?php get_footer(); ?>

